Spaces:
Runtime error
Runtime error
barathm111
commited on
Commit
•
eee6a7e
1
Parent(s):
d29a8b2
Upload app.py
Browse files
app.py
ADDED
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from performance_analyzer import CollegePerformanceAnalyzer
|
3 |
+
|
4 |
+
def run_performance_analysis(seed: int = None, use_ai_insights: bool = True):
|
5 |
+
"""
|
6 |
+
Main function to orchestrate college performance analysis.
|
7 |
+
|
8 |
+
Args:
|
9 |
+
seed (int, optional): Random seed for reproducible results
|
10 |
+
use_ai_insights (bool): Toggle AI-generated strategic insights
|
11 |
+
|
12 |
+
Returns:
|
13 |
+
Comprehensive performance analysis report
|
14 |
+
"""
|
15 |
+
# Initialize performance analyzer
|
16 |
+
analyzer = CollegePerformanceAnalyzer()
|
17 |
+
|
18 |
+
# Generate performance scores
|
19 |
+
parameters = analyzer.generate_performance_scores(seed)
|
20 |
+
|
21 |
+
# Calculate comprehensive metrics
|
22 |
+
analysis_results = analyzer.calculate_weighted_metrics(parameters)
|
23 |
+
|
24 |
+
# Generate feedback based on user preference
|
25 |
+
ai_feedback = (
|
26 |
+
analyzer.generate_ai_feedback(analysis_results)
|
27 |
+
if use_ai_insights
|
28 |
+
else analyzer._generate_manual_feedback(analysis_results)
|
29 |
+
)
|
30 |
+
|
31 |
+
# Combine performance report with strategic insights
|
32 |
+
report = f"""
|
33 |
+
# 🎓 College Performance Analysis Report
|
34 |
+
|
35 |
+
## Performance Metrics
|
36 |
+
|
37 |
+
{' '.join([
|
38 |
+
f"**{details['full_name']}**: {details['score']}/100 "
|
39 |
+
for param, details in analysis_results['parameters'].items()
|
40 |
+
])}
|
41 |
+
|
42 |
+
## Overall Performance
|
43 |
+
|
44 |
+
- **Total Weighted Score**: {analysis_results['total_weighted_score']:.2f}
|
45 |
+
- **Predicted NIRF Rank**: {analysis_results['nirf_rank']}
|
46 |
+
- **Institutional Rating**: {analysis_results['overall_rating']}/5
|
47 |
+
|
48 |
+
## Strategic Insights
|
49 |
+
|
50 |
+
{ai_feedback}
|
51 |
+
"""
|
52 |
+
|
53 |
+
return report
|
54 |
+
|
55 |
+
def create_gradio_interface():
|
56 |
+
"""
|
57 |
+
Create interactive Gradio web interface for performance analysis.
|
58 |
+
"""
|
59 |
+
iface = gr.Interface(
|
60 |
+
fn=run_performance_analysis,
|
61 |
+
inputs=[
|
62 |
+
gr.Number(label="Random Seed (Optional)", precision=0, optional=True),
|
63 |
+
gr.Checkbox(label="Generate AI Insights", value=True)
|
64 |
+
],
|
65 |
+
outputs=gr.Markdown(label="Performance Analysis Report"),
|
66 |
+
title="🏫 College Performance Analyzer",
|
67 |
+
description="Generate comprehensive performance insights with optional AI-powered strategic analysis.",
|
68 |
+
theme="default"
|
69 |
+
)
|
70 |
+
return iface
|
71 |
+
|
72 |
+
if __name__ == "__main__":
|
73 |
+
interface = create_gradio_interface()
|
74 |
+
interface.launch()
|