File size: 2,415 Bytes
d29a8b2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import gradio as gr
from performance_analyzer import CollegePerformanceAnalyzer

def run_performance_analysis(seed: int = None, use_ai_insights: bool = True):
    """

    Main function to orchestrate college performance analysis.

    

    Args:

        seed (int, optional): Random seed for reproducible results

        use_ai_insights (bool): Toggle AI-generated strategic insights

    

    Returns:

        Comprehensive performance analysis report

    """
    # Initialize performance analyzer
    analyzer = CollegePerformanceAnalyzer()
    
    # Generate performance scores
    parameters = analyzer.generate_performance_scores(seed)
    
    # Calculate comprehensive metrics
    analysis_results = analyzer.calculate_weighted_metrics(parameters)
    
    # Generate feedback based on user preference
    ai_feedback = (
        analyzer.generate_ai_feedback(analysis_results) 
        if use_ai_insights 
        else analyzer._generate_manual_feedback(analysis_results)
    )
    
    # Combine performance report with strategic insights
    report = f"""

    # 🎓 College Performance Analysis Report



    ## Performance Metrics



    {' '.join([

        f"**{details['full_name']}**: {details['score']}/100 "

        for param, details in analysis_results['parameters'].items()

    ])}



    ## Overall Performance



    - **Total Weighted Score**: {analysis_results['total_weighted_score']:.2f}

    - **Predicted NIRF Rank**: {analysis_results['nirf_rank']}

    - **Institutional Rating**: {analysis_results['overall_rating']}/5



    ## Strategic Insights



    {ai_feedback}

    """
    
    return report

def create_gradio_interface():
    """

    Create interactive Gradio web interface for performance analysis.

    """
    iface = gr.Interface(
        fn=run_performance_analysis,
        inputs=[
            gr.Number(label="Random Seed (Optional)", precision=0, optional=True),
            gr.Checkbox(label="Generate AI Insights", value=True)
        ],
        outputs=gr.Markdown(label="Performance Analysis Report"),
        title="🏫 College Performance Analyzer",
        description="Generate comprehensive performance insights with optional AI-powered strategic analysis.",
        theme="default"
    )
    return iface

if __name__ == "__main__":
    interface = create_gradio_interface()
    interface.launch()