ProfessorLeVesseur
commited on
Update data_processor.py
Browse files- data_processor.py +11 -12
data_processor.py
CHANGED
@@ -188,9 +188,6 @@
|
|
188 |
|
189 |
|
190 |
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
import re
|
195 |
import pandas as pd
|
196 |
import os
|
@@ -277,7 +274,7 @@ class DataProcessor:
|
|
277 |
return self.intervention_column
|
278 |
|
279 |
def compute_intervention_statistics(self, df):
|
280 |
-
intervention_column = self.
|
281 |
total_days = len(df)
|
282 |
sessions_held = df[intervention_column].str.strip().str.lower().eq('yes').sum()
|
283 |
intervention_frequency = (sessions_held / total_days) * 100 if total_days > 0 else 0
|
@@ -337,9 +334,6 @@ class DataProcessor:
|
|
337 |
|
338 |
total_sessions = sum(engagement_counts.values())
|
339 |
|
340 |
-
engagement_pct = (engagement_counts[self.ENGAGED_STR] / total_sessions * 100) if total_sessions > 0 else 0
|
341 |
-
engagement_pct = round(engagement_pct)
|
342 |
-
|
343 |
engaged_pct = (engagement_counts[self.ENGAGED_STR] / total_sessions * 100) if total_sessions > 0 else 0
|
344 |
engaged_pct = round(engaged_pct)
|
345 |
|
@@ -352,11 +346,15 @@ class DataProcessor:
|
|
352 |
absent_pct = (engagement_counts['Absent'] / total_sessions * 100) if total_sessions > 0 else 0
|
353 |
absent_pct = round(absent_pct)
|
354 |
|
|
|
|
|
|
|
|
|
355 |
# Determine if the student attended ≥ 90% of sessions
|
356 |
attended_90 = "Yes" if attendance_pct >= 90 else "No"
|
357 |
|
358 |
# Determine if the student was engaged ≥ 80% of the time
|
359 |
-
engaged_80 = "Yes" if
|
360 |
|
361 |
# Store metrics in the required order
|
362 |
student_metrics[student_name] = {
|
@@ -377,10 +375,10 @@ class DataProcessor:
|
|
377 |
|
378 |
def compute_average_metrics(self, student_metrics_df):
|
379 |
# Calculate the attendance and engagement average percentages across students
|
380 |
-
attendance_avg_stats = student_metrics_df['Attendance (%)'].mean() #
|
381 |
-
engagement_avg_stats = student_metrics_df['Engagement (%)'].mean() #
|
382 |
|
383 |
-
# Round the averages to
|
384 |
attendance_avg_stats = round(attendance_avg_stats)
|
385 |
engagement_avg_stats = round(engagement_avg_stats)
|
386 |
|
@@ -391,4 +389,5 @@ class DataProcessor:
|
|
391 |
return "Address Attendance"
|
392 |
elif row["Engagement ≥ 80%"] == "No":
|
393 |
return "Address Engagement"
|
394 |
-
|
|
|
|
188 |
|
189 |
|
190 |
|
|
|
|
|
|
|
191 |
import re
|
192 |
import pandas as pd
|
193 |
import os
|
|
|
274 |
return self.intervention_column
|
275 |
|
276 |
def compute_intervention_statistics(self, df):
|
277 |
+
intervention_column = self.get_intervention_column(df)
|
278 |
total_days = len(df)
|
279 |
sessions_held = df[intervention_column].str.strip().str.lower().eq('yes').sum()
|
280 |
intervention_frequency = (sessions_held / total_days) * 100 if total_days > 0 else 0
|
|
|
334 |
|
335 |
total_sessions = sum(engagement_counts.values())
|
336 |
|
|
|
|
|
|
|
337 |
engaged_pct = (engagement_counts[self.ENGAGED_STR] / total_sessions * 100) if total_sessions > 0 else 0
|
338 |
engaged_pct = round(engaged_pct)
|
339 |
|
|
|
346 |
absent_pct = (engagement_counts['Absent'] / total_sessions * 100) if total_sessions > 0 else 0
|
347 |
absent_pct = round(absent_pct)
|
348 |
|
349 |
+
# Engagement percentage is based on Engaged and Partially Engaged sessions
|
350 |
+
engagement_pct = ((engagement_counts[self.ENGAGED_STR] + engagement_counts[self.PARTIALLY_ENGAGED_STR]) / total_sessions * 100) if total_sessions > 0 else 0
|
351 |
+
engagement_pct = round(engagement_pct)
|
352 |
+
|
353 |
# Determine if the student attended ≥ 90% of sessions
|
354 |
attended_90 = "Yes" if attendance_pct >= 90 else "No"
|
355 |
|
356 |
# Determine if the student was engaged ≥ 80% of the time
|
357 |
+
engaged_80 = "Yes" if engagement_pct >= 80 else "No"
|
358 |
|
359 |
# Store metrics in the required order
|
360 |
student_metrics[student_name] = {
|
|
|
375 |
|
376 |
def compute_average_metrics(self, student_metrics_df):
|
377 |
# Calculate the attendance and engagement average percentages across students
|
378 |
+
attendance_avg_stats = student_metrics_df['Attendance (%)'].mean() # Average attendance percentage
|
379 |
+
engagement_avg_stats = student_metrics_df['Engagement (%)'].mean() # Average engagement percentage
|
380 |
|
381 |
+
# Round the averages to whole numbers
|
382 |
attendance_avg_stats = round(attendance_avg_stats)
|
383 |
engagement_avg_stats = round(engagement_avg_stats)
|
384 |
|
|
|
389 |
return "Address Attendance"
|
390 |
elif row["Engagement ≥ 80%"] == "No":
|
391 |
return "Address Engagement"
|
392 |
+
else:
|
393 |
+
return "Consider barriers, fidelity, and progress monitoring"
|