Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -203,16 +203,21 @@ def clean_answer(answer):
|
|
| 203 |
return clean[0].upper() if clean else None
|
| 204 |
|
| 205 |
def update_leaderboard(results):
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 216 |
|
| 217 |
def load_leaderboard():
|
| 218 |
if not os.path.exists(LEADERBOARD_FILE) or os.stat(LEADERBOARD_FILE).st_size == 0:
|
|
|
|
| 203 |
return clean[0].upper() if clean else None
|
| 204 |
|
| 205 |
def update_leaderboard(results):
|
| 206 |
+
try:
|
| 207 |
+
new_entry = {
|
| 208 |
+
"Model Name": results['model_name'],
|
| 209 |
+
"Overall Accuracy": round(results['overall_accuracy'] * 100, 2),
|
| 210 |
+
"Valid Accuracy": round(results['valid_accuracy'] * 100, 2),
|
| 211 |
+
"Correct Predictions": results['correct_predictions'],
|
| 212 |
+
"Total Questions": results['total_questions'],
|
| 213 |
+
"Timestamp": datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
|
| 214 |
+
}
|
| 215 |
+
new_entry_df = pd.DataFrame([new_entry])
|
| 216 |
+
new_entry_df.to_csv(LEADERBOARD_FILE, mode='a', index=False, header=not os.path.exists(LEADERBOARD_FILE))
|
| 217 |
+
print("Leaderboard updated successfully!")
|
| 218 |
+
except Exception as e:
|
| 219 |
+
print(f"Error while updating leaderboard: {e}")
|
| 220 |
+
|
| 221 |
|
| 222 |
def load_leaderboard():
|
| 223 |
if not os.path.exists(LEADERBOARD_FILE) or os.stat(LEADERBOARD_FILE).st_size == 0:
|