ProfessorLeVesseur commited on
Commit
47e386b
·
verified ·
1 Parent(s): ed32cdb

Create main.py

Browse files
Files changed (1) hide show
  1. main.py +82 -0
main.py ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from app_config import AppConfig
3
+ from data_processor import DataProcessor
4
+ from visualization import Visualization
5
+ from ai_analysis import AIAnalysis
6
+
7
+ def main():
8
+ # Initialize the app configuration
9
+ app_config = AppConfig()
10
+
11
+ # Initialize the data processor
12
+ data_processor = DataProcessor()
13
+
14
+ # Initialize the visualization handler
15
+ visualization = Visualization()
16
+
17
+ # Initialize the AI analysis handler
18
+ ai_analysis = AIAnalysis(data_processor.client)
19
+
20
+ st.title("Intervention Program Analysis")
21
+
22
+ # File uploader
23
+ uploaded_file = st.file_uploader("Upload your Excel file", type=["xlsx"])
24
+
25
+ if uploaded_file is not None:
26
+ try:
27
+ # Read the Excel file into a DataFrame
28
+ df = data_processor.read_excel(uploaded_file)
29
+
30
+ # Format the session data
31
+ df = data_processor.format_session_data(df)
32
+
33
+ # Replace student names with initials
34
+ df = data_processor.replace_student_names_with_initials(df)
35
+
36
+ st.subheader("Uploaded Data")
37
+ st.write(df)
38
+
39
+ # Ensure expected column is available
40
+ if DataProcessor.INTERVENTION_COLUMN not in df.columns:
41
+ st.error(f"Expected column '{DataProcessor.INTERVENTION_COLUMN}' not found.")
42
+ return
43
+
44
+ # Compute Intervention Session Statistics
45
+ intervention_stats = data_processor.compute_intervention_statistics(df)
46
+ st.subheader("Intervention Session Statistics")
47
+ st.write(intervention_stats)
48
+
49
+ # Plot and download intervention statistics
50
+ intervention_fig = visualization.plot_intervention_statistics(intervention_stats)
51
+ visualization.download_chart(intervention_fig, "intervention_statistics_chart.png")
52
+
53
+ # Compute Student Metrics
54
+ student_metrics_df = data_processor.compute_student_metrics(df)
55
+ st.subheader("Student Metrics")
56
+ st.write(student_metrics_df)
57
+
58
+ # Compute Student Metric Averages
59
+ attendance_avg_stats, engagement_avg_stats = data_processor.compute_average_metrics(student_metrics_df)
60
+
61
+ # Plot and download student metrics
62
+ student_metrics_fig = visualization.plot_student_metrics(student_metrics_df, attendance_avg_stats, engagement_avg_stats)
63
+ visualization.download_chart(student_metrics_fig, "student_metrics_chart.png")
64
+
65
+ # Prepare input for the language model
66
+ llm_input = ai_analysis.prepare_llm_input(student_metrics_df)
67
+
68
+ # Generate Notes and Recommendations using Hugging Face LLM
69
+ with st.spinner("Generating AI analysis..."):
70
+ recommendations = ai_analysis.prompt_response_from_hf_llm(llm_input)
71
+
72
+ st.subheader("AI Analysis")
73
+ st.markdown(recommendations)
74
+
75
+ # Download AI output
76
+ ai_analysis.download_llm_output(recommendations, "llm_output.txt")
77
+
78
+ except Exception as e:
79
+ st.error(f"Error reading the file: {str(e)}")
80
+
81
+ if __name__ == '__main__':
82
+ main()