ProfessorLeVesseur commited on
Commit
6d686bf
·
verified ·
1 Parent(s): a6c607c

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +0 -189
main.py CHANGED
@@ -1,192 +1,3 @@
1
- # import streamlit as st
2
- # import pandas as pd
3
- # from app_config import AppConfig # Import the configurations class
4
- # from data_processor import DataProcessor # Import the data analysis class
5
- # from visualization import Visualization # Import the data viz class
6
- # from ai_analysis import AIAnalysis # Import the ai analysis class
7
- # from sidebar import Sidebar # Import the Sidebar class
8
- # from report import ReportGenerator
9
-
10
- # def main():
11
- # # Initialize the app configuration
12
- # app_config = AppConfig()
13
-
14
- # # Initialize the session state
15
- # if 'ai_recommendations' not in st.session_state:
16
- # st.session_state.ai_recommendations = None
17
-
18
- # # Initialize the sidebar
19
- # sidebar = Sidebar()
20
- # sidebar.display()
21
-
22
- # # Initialize the data processor
23
- # data_processor = DataProcessor()
24
-
25
- # # Initialize the visualization handler
26
- # visualization = Visualization()
27
-
28
- # # Initialize the AI analysis handler
29
- # ai_analysis = AIAnalysis(data_processor.client)
30
-
31
- # st.title("Literacy Implementation Record Data Analysis")
32
-
33
- # # Add the descriptive text
34
- # st.markdown("""
35
- # This tool summarizes implementation record data for student attendance, engagement, and intervention dosage to address hypothesis #1: Have Students Received Adequate Instruction?
36
- # """)
37
-
38
- # # Date selection option
39
- # date_option = st.radio(
40
- # "Select data range:",
41
- # ("All Data", "Date Range")
42
- # )
43
-
44
- # # Initialize start and end date variables
45
- # start_date = None
46
- # end_date = None
47
-
48
- # if date_option == "Date Range":
49
- # # Prompt user to enter start and end dates
50
- # start_date = st.date_input("Start Date")
51
- # end_date = st.date_input("End Date")
52
-
53
- # # Ensure start date is before end date
54
- # if start_date > end_date:
55
- # st.error("Start date must be before end date.")
56
- # return
57
-
58
- # # File uploader
59
- # uploaded_file = st.file_uploader("Upload your Excel file", type=["xlsx"])
60
-
61
- # if uploaded_file is not None:
62
- # try:
63
- # # Read the Excel file into a DataFrame
64
- # df = data_processor.read_excel(uploaded_file)
65
-
66
- # # Format the session data
67
- # df = data_processor.format_session_data(df)
68
-
69
- # # Replace student names with initials
70
- # df = data_processor.replace_student_names_with_initials(df)
71
-
72
- # # Filter data if date range is selected
73
- # if date_option == "Date Range":
74
- # # Convert start_date and end_date to datetime
75
- # start_date = pd.to_datetime(start_date).date()
76
- # end_date = pd.to_datetime(end_date).date()
77
-
78
- # # Identify the date column
79
- # date_column = next((col for col in df.columns if col in ["Date of Session", "Date"]), None)
80
- # if date_column:
81
- # # Filter the DataFrame based on the selected date range
82
- # df = df[(df[date_column] >= start_date) & (df[date_column] <= end_date)]
83
- # else:
84
- # st.error("Date column not found in the data.")
85
- # return
86
-
87
- # st.subheader("Uploaded Data")
88
- # st.write(df)
89
-
90
- # # Ensure the intervention column is determined
91
- # intervention_column = data_processor.get_intervention_column(df)
92
- # if intervention_column not in df.columns:
93
- # st.error(f"Expected column '{intervention_column}' not found.")
94
- # return
95
-
96
- # # Compute Intervention Session Statistics
97
- # intervention_stats = data_processor.compute_intervention_statistics(df)
98
- # st.subheader("Intervention Dosage")
99
- # st.write(intervention_stats)
100
-
101
- # # Plot and download intervention statistics: Two-column layout for the visualization and intervention frequency
102
- # col1, col2 = st.columns([3, 1]) # Set the column width ratio
103
-
104
- # with col1:
105
- # intervention_fig = visualization.plot_intervention_statistics(intervention_stats)
106
-
107
- # with col2:
108
- # intervention_frequency = intervention_stats['Intervention Dosage (%)'].values[0]
109
- # # Display the "Intervention Dosage (%)" text
110
- # st.markdown("<h3 style='color: #358E66;'>Intervention Dosage</h3>", unsafe_allow_html=True)
111
- # # Display the frequency value below it
112
- # st.markdown(f"<h1 style='color: #358E66;'>{intervention_frequency}%</h1>", unsafe_allow_html=True)
113
-
114
- # visualization.download_chart(intervention_fig, "intervention_statistics_chart.png")
115
-
116
- # # Compute Student Metrics
117
- # student_metrics_df = data_processor.compute_student_metrics(df)
118
- # st.subheader("Student Attendance and Engagement")
119
- # st.write(student_metrics_df)
120
-
121
- # # Compute Student Metric Averages
122
- # attendance_avg_stats, engagement_avg_stats = data_processor.compute_average_metrics(student_metrics_df)
123
-
124
- # # Plot and download student metrics
125
- # student_metrics_fig = visualization.plot_student_metrics(student_metrics_df, attendance_avg_stats, engagement_avg_stats)
126
- # visualization.download_chart(student_metrics_fig, "student_metrics_chart.png")
127
-
128
- # # Evaluate each student and build decision tree diagrams
129
- # student_metrics_df['Evaluation'] = student_metrics_df.apply(
130
- # lambda row: data_processor.evaluate_student(row), axis=1
131
- # )
132
- # st.subheader("Student Evaluations")
133
- # st.write(student_metrics_df[['Student', 'Evaluation']])
134
-
135
- # # Build and display decision tree diagrams for each student
136
- # for index, row in student_metrics_df.iterrows():
137
- # tree_diagram = visualization.build_tree_diagram(row)
138
-
139
- # # Get the student's name from the DataFrame
140
- # student_name = row['Student']
141
-
142
- # # Use st.expander to wrap the graphviz chart with the student's name
143
- # with st.expander(f"{student_name} Decision Tree", expanded=False):
144
- # st.graphviz_chart(tree_diagram.source)
145
-
146
- # # Generate Notes and Recommendations using LLM
147
- # if st.session_state.ai_recommendations is None:
148
- # with st.spinner("Generating MTSS.ai Analysis..."):
149
- # llm_input = ai_analysis.prepare_llm_input(student_metrics_df)
150
- # # recommendations = ai_analysis.prompt_response_from_hf_llm(llm_input)
151
- # recommendations = ai_analysis.prompt_response_from_mistral_llm(llm_input)
152
- # st.session_state.ai_recommendations = recommendations
153
-
154
- # # Display the recommendations
155
- # st.subheader("MTSS.ai Analysis")
156
- # # st.markdown(recommendations)
157
- # st.markdown(st.session_state.ai_recommendations)
158
-
159
- # # Download AI output
160
- # # ai_analysis.download_llm_output(recommendations, "MTSSai_Report.txt")
161
- # ai_analysis.download_llm_output(st.session_state.ai_recommendations, "MTSSai_Report.txt")
162
-
163
- # # Generate the PDF Report using the stored recommendations
164
- # report_gen = ReportGenerator()
165
- # combined_pdf = report_gen.create_combined_pdf(
166
- # intervention_fig,
167
- # student_metrics_fig,
168
- # st.session_state.ai_recommendations
169
- # )
170
-
171
- # # Add the download button for the PDF
172
- # st.download_button(
173
- # label="Download MTSS.ai Report (PDF)",
174
- # data=combined_pdf,
175
- # file_name="MTSSai_LIR_Report.pdf",
176
- # mime="application/pdf",
177
- # icon="📄",
178
- # use_container_width=True
179
- # )
180
-
181
- # except Exception as e:
182
- # st.error(f"Error processing the file: {str(e)}")
183
-
184
- # if __name__ == '__main__':
185
- # main()
186
-
187
-
188
-
189
-
190
  import streamlit as st
191
  import pandas as pd
192
  from app_config import AppConfig # Import the configurations class
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import streamlit as st
2
  import pandas as pd
3
  from app_config import AppConfig # Import the configurations class