ProfessorLeVesseur commited on
Commit
b761683
·
verified ·
1 Parent(s): 1544322

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -15
app.py CHANGED
@@ -130,6 +130,9 @@ ENGAGED_STR = 'Engaged (Respect, Responsibility, Effort)'
130
  PARTIALLY_ENGAGED_STR = 'Partially Engaged (about 50%)'
131
  NOT_ENGAGED_STR = 'Not Engaged (less than 50%)'
132
 
 
 
 
133
  def main():
134
  st.title("Intervention Program Analysis")
135
 
@@ -138,67 +141,73 @@ def main():
138
 
139
  if uploaded_file is not None:
140
  try:
141
- # Read the Excel file into a DataFrame
142
- # df = pd.read_excel(uploaded_file)
143
 
144
- # Rename duplicate columns to make them unique
 
145
  cols = pd.Series(df.columns)
146
  for dup in cols[cols.duplicated()].unique():
147
  cols[cols[cols == dup].index.values.tolist()] = [f"{dup}_{i+1}" if i != 0 else dup for i in range(sum(cols == dup))]
148
  df.columns = cols
149
 
150
- # Replace student names with initials
151
  df = replace_student_names_with_initials(df)
152
 
 
153
  st.subheader("Uploaded Data")
154
  st.write(df)
155
 
156
- # Ensure expected column is available
157
  if INTERVENTION_COLUMN not in df.columns:
158
  st.error(f"Expected column '{INTERVENTION_COLUMN}' not found.")
159
  return
160
 
161
- # Clean up column names
162
  df.columns = df.columns.str.strip()
163
 
164
- # Compute Intervention Session Statistics
165
  intervention_stats = compute_intervention_statistics(df)
166
  st.subheader("Intervention Session Statistics")
167
  st.write(intervention_stats)
168
 
169
- # Visualization for Intervention Session Statistics
170
  intervention_fig = plot_intervention_statistics(intervention_stats)
171
 
172
- # Add download button for Intervention Session Statistics chart
173
  download_chart(intervention_fig, "intervention_statistics_chart.png")
174
 
175
- # Compute Student Metrics
176
  student_metrics_df = compute_student_metrics(df)
177
  st.subheader("Student Metrics")
178
  st.write(student_metrics_df)
179
 
180
- # Visualization for Student Metrics
181
  student_metrics_fig = plot_student_metrics(student_metrics_df)
182
 
183
- # Add download button for Student Metrics chart
184
  download_chart(student_metrics_fig, "student_metrics_chart.png")
185
 
186
- # Prepare input for the language model
187
  llm_input = prepare_llm_input(student_metrics_df)
188
 
189
- # Generate Notes and Recommendations using Hugging Face LLM
190
  with st.spinner("Generating AI analysis..."):
191
  recommendations = prompt_response_from_hf_llm(llm_input)
192
 
 
193
  st.subheader("AI Analysis")
194
  st.markdown(recommendations)
195
 
196
- # Add download button for LLM output
197
  download_llm_output(recommendations, "llm_output.txt")
198
 
199
  except Exception as e:
200
  st.error(f"Error reading the file: {str(e)}")
201
 
 
 
 
202
  def replace_student_names_with_initials(df):
203
  """Replace student names in column headers with initials."""
204
  updated_columns = []
 
130
  PARTIALLY_ENGAGED_STR = 'Partially Engaged (about 50%)'
131
  NOT_ENGAGED_STR = 'Not Engaged (less than 50%)'
132
 
133
+ import streamlit as st
134
+ import pandas as pd
135
+
136
  def main():
137
  st.title("Intervention Program Analysis")
138
 
 
141
 
142
  if uploaded_file is not None:
143
  try:
144
+ # Step 1: Read the Excel file into a DataFrame
145
+ df = pd.read_excel(uploaded_file)
146
 
147
+ # Step 2: Rename duplicate columns to make them unique
148
+ # Using built-in pandas functionality to handle duplicate column names
149
  cols = pd.Series(df.columns)
150
  for dup in cols[cols.duplicated()].unique():
151
  cols[cols[cols == dup].index.values.tolist()] = [f"{dup}_{i+1}" if i != 0 else dup for i in range(sum(cols == dup))]
152
  df.columns = cols
153
 
154
+ # Step 3: Replace student names with initials
155
  df = replace_student_names_with_initials(df)
156
 
157
+ # Step 4: Display the uploaded data
158
  st.subheader("Uploaded Data")
159
  st.write(df)
160
 
161
+ # Step 5: Ensure expected column is available
162
  if INTERVENTION_COLUMN not in df.columns:
163
  st.error(f"Expected column '{INTERVENTION_COLUMN}' not found.")
164
  return
165
 
166
+ # Step 6: Clean up column names
167
  df.columns = df.columns.str.strip()
168
 
169
+ # Step 7: Compute and Display Intervention Session Statistics
170
  intervention_stats = compute_intervention_statistics(df)
171
  st.subheader("Intervention Session Statistics")
172
  st.write(intervention_stats)
173
 
174
+ # Step 8: Visualization for Intervention Session Statistics
175
  intervention_fig = plot_intervention_statistics(intervention_stats)
176
 
177
+ # Step 9: Add download button for Intervention Session Statistics chart
178
  download_chart(intervention_fig, "intervention_statistics_chart.png")
179
 
180
+ # Step 10: Compute Student Metrics
181
  student_metrics_df = compute_student_metrics(df)
182
  st.subheader("Student Metrics")
183
  st.write(student_metrics_df)
184
 
185
+ # Step 11: Visualization for Student Metrics
186
  student_metrics_fig = plot_student_metrics(student_metrics_df)
187
 
188
+ # Step 12: Add download button for Student Metrics chart
189
  download_chart(student_metrics_fig, "student_metrics_chart.png")
190
 
191
+ # Step 13: Prepare input for the language model
192
  llm_input = prepare_llm_input(student_metrics_df)
193
 
194
+ # Step 14: Generate Notes and Recommendations using Hugging Face LLM
195
  with st.spinner("Generating AI analysis..."):
196
  recommendations = prompt_response_from_hf_llm(llm_input)
197
 
198
+ # Step 15: Display AI Analysis
199
  st.subheader("AI Analysis")
200
  st.markdown(recommendations)
201
 
202
+ # Step 16: Add download button for LLM output
203
  download_llm_output(recommendations, "llm_output.txt")
204
 
205
  except Exception as e:
206
  st.error(f"Error reading the file: {str(e)}")
207
 
208
+ if __name__ == "__main__":
209
+ main()
210
+
211
  def replace_student_names_with_initials(df):
212
  """Replace student names in column headers with initials."""
213
  updated_columns = []