ProfessorLeVesseur commited on
Commit
f5e1694
·
verified ·
1 Parent(s): 4eb355c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -1
app.py CHANGED
@@ -211,7 +211,7 @@ def main():
211
  with col2:
212
  intervention_frequency = intervention_stats['Intervention Frequency (%)'].values[0]
213
  # Display the "Intervention Frequency (%)" text
214
- st.markdown("<h3 style='color: #358E66;'>Intervention Frequency</h2>", unsafe_allow_html=True)
215
  # Display the frequency value below it
216
  st.markdown(f"<h1 style='color: #358E66;'>{intervention_frequency}%</h1>", unsafe_allow_html=True)
217
 
@@ -226,6 +226,28 @@ def main():
226
  # Visualization for Student Metrics
227
  student_metrics_fig = plot_student_metrics(student_metrics_df)
228
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
229
  # Add download button for Student Metrics chart
230
  download_chart(student_metrics_fig, "student_metrics_chart.png")
231
 
@@ -407,6 +429,19 @@ def compute_student_metrics(df):
407
  student_metrics_df.rename(columns={'index': 'Student'}, inplace=True)
408
  return student_metrics_df
409
 
 
 
 
 
 
 
 
 
 
 
 
 
 
410
  def plot_student_metrics(student_metrics_df):
411
  # Create the figure and axis
412
  fig, ax = plt.subplots(figsize=(10, 6)) # Increased figure size for better readability
 
211
  with col2:
212
  intervention_frequency = intervention_stats['Intervention Frequency (%)'].values[0]
213
  # Display the "Intervention Frequency (%)" text
214
+ st.markdown("<h3 style='color: #358E66;'>Intervention Frequency</h3>", unsafe_allow_html=True)
215
  # Display the frequency value below it
216
  st.markdown(f"<h1 style='color: #358E66;'>{intervention_frequency}%</h1>", unsafe_allow_html=True)
217
 
 
226
  # Visualization for Student Metrics
227
  student_metrics_fig = plot_student_metrics(student_metrics_df)
228
 
229
+ # NEW Expanded version of Visualization for Student Metrics
230
+ # Two-column layout for the visualization and intervention frequency
231
+ col1, col2 = st.columns([3, 1]) # Set the column width ratio
232
+
233
+ with col1:
234
+ student_metrics_fig = plot_student_metrics(student_metrics_df)
235
+
236
+ with col2:
237
+ # Display the "Attendance Average (%)" text and value
238
+ st.markdown("<h4 style='color: #358E66;'>Attendance Average (%)</h4>", unsafe_allow_html=True)
239
+ if attendance_avg_stats is not None:
240
+ st.markdown(f"<h2 style='color: #358E66;'>{attendance_avg_stats}%</h2>", unsafe_allow_html=True)
241
+ else:
242
+ st.markdown("<h2 style='color: #358E66;'>N/A</h2>", unsafe_allow_html=True)
243
+
244
+ # Display the "Engagement Average (%)" text and value
245
+ st.markdown("<h4 style='color: #358E66;'>Engagement Average (%)</h4>", unsafe_allow_html=True)
246
+ if engagement_avg_stats is not None:
247
+ st.markdown(f"<h2 style='color: #358E66;'>{engagement_avg_stats}%</h2>", unsafe_allow_html=True)
248
+ else:
249
+ st.markdown("<h2 style='color: #358E66;'>N/A</h2>", unsafe_allow_html=True)
250
+
251
  # Add download button for Student Metrics chart
252
  download_chart(student_metrics_fig, "student_metrics_chart.png")
253
 
 
429
  student_metrics_df.rename(columns={'index': 'Student'}, inplace=True)
430
  return student_metrics_df
431
 
432
+ #NEW
433
+ def compute_average_metrics(student_metrics_df):
434
+ # Calculate the attendance and engagement average percentages across students
435
+ attendance_avg_stats = student_metrics_df['Attendance (%)'].mean() # Calculate the average attendance percentage
436
+ engagement_avg_stats = student_metrics_df['Engagement (%)'].mean() # Calculate the average engagement percentage
437
+
438
+ # Round the averages to make them whole numbers
439
+ attendance_avg_stats = round(attendance_avg_stats)
440
+ engagement_avg_stats = round(engagement_avg_stats)
441
+
442
+ return attendance_avg_stats, engagement_avg_stats
443
+
444
+
445
  def plot_student_metrics(student_metrics_df):
446
  # Create the figure and axis
447
  fig, ax = plt.subplots(figsize=(10, 6)) # Increased figure size for better readability