Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
|
@@ -105,13 +105,13 @@ def process_data(input_data: CoachingCodeInput):
|
|
| 105 |
# Step 4: Merge all data
|
| 106 |
merged_data = pd.merge(merged_journal_panic, test_df_processed, on='user_id', how='outer')
|
| 107 |
merged_data_cleaned = merged_data.dropna(subset=['productivity_yes_no', 'productivity_rate', 'panic_button', 'test_chapter'], how='all')
|
| 108 |
-
|
| 109 |
# Step 5: Process Data
|
| 110 |
df = pd.DataFrame(merged_data_cleaned)
|
| 111 |
academic_weights = {'BACKLOGS': -5, 'MISSED CLASSES': -4, 'NOT UNDERSTANDING': -3, 'BAD MARKS': -3, 'LACK OF MOTIVATION': -3}
|
| 112 |
non_academic_weights = {'EMOTIONAL FACTORS': -3, 'PROCRASTINATE': -2, 'LOST INTEREST': -4, 'LACK OF FOCUS': -2, 'GOALS NOT ACHIEVED': -2, 'LACK OF DISCIPLINE': -2}
|
| 113 |
max_weighted_panic_score = sum([max(academic_weights.values()) * 3, max(non_academic_weights.values()) * 3])
|
| 114 |
-
|
| 115 |
def calculate_potential_score(row):
|
| 116 |
test_score_normalized = 0
|
| 117 |
if row['test_scores']:
|
|
@@ -131,10 +131,11 @@ def process_data(input_data: CoachingCodeInput):
|
|
| 131 |
|
| 132 |
total_potential_score = test_score_normalized + panic_score + journal_score
|
| 133 |
return total_potential_score
|
| 134 |
-
|
| 135 |
merged_df = df.groupby('user_id').apply(lambda group: pd.Series({
|
| 136 |
'potential_score': calculate_potential_score(group)
|
| 137 |
})).reset_index()
|
|
|
|
| 138 |
|
| 139 |
merged_df['potential_score'] = merged_df['potential_score'].round(2)
|
| 140 |
sorted_df = merged_df[['user_id', 'potential_score']].sort_values(by='potential_score', ascending=False)
|
|
|
|
| 105 |
# Step 4: Merge all data
|
| 106 |
merged_data = pd.merge(merged_journal_panic, test_df_processed, on='user_id', how='outer')
|
| 107 |
merged_data_cleaned = merged_data.dropna(subset=['productivity_yes_no', 'productivity_rate', 'panic_button', 'test_chapter'], how='all')
|
| 108 |
+
print("all data merged")
|
| 109 |
# Step 5: Process Data
|
| 110 |
df = pd.DataFrame(merged_data_cleaned)
|
| 111 |
academic_weights = {'BACKLOGS': -5, 'MISSED CLASSES': -4, 'NOT UNDERSTANDING': -3, 'BAD MARKS': -3, 'LACK OF MOTIVATION': -3}
|
| 112 |
non_academic_weights = {'EMOTIONAL FACTORS': -3, 'PROCRASTINATE': -2, 'LOST INTEREST': -4, 'LACK OF FOCUS': -2, 'GOALS NOT ACHIEVED': -2, 'LACK OF DISCIPLINE': -2}
|
| 113 |
max_weighted_panic_score = sum([max(academic_weights.values()) * 3, max(non_academic_weights.values()) * 3])
|
| 114 |
+
print("step 5 : data processing done")
|
| 115 |
def calculate_potential_score(row):
|
| 116 |
test_score_normalized = 0
|
| 117 |
if row['test_scores']:
|
|
|
|
| 131 |
|
| 132 |
total_potential_score = test_score_normalized + panic_score + journal_score
|
| 133 |
return total_potential_score
|
| 134 |
+
|
| 135 |
merged_df = df.groupby('user_id').apply(lambda group: pd.Series({
|
| 136 |
'potential_score': calculate_potential_score(group)
|
| 137 |
})).reset_index()
|
| 138 |
+
print("step 6 : data merged_df")
|
| 139 |
|
| 140 |
merged_df['potential_score'] = merged_df['potential_score'].round(2)
|
| 141 |
sorted_df = merged_df[['user_id', 'potential_score']].sort_values(by='potential_score', ascending=False)
|