Update app.py
Browse files
app.py
CHANGED
|
@@ -533,6 +533,21 @@ def evaluate_predictions(prediction_file, model_name,Team_name ,add_to_leaderboa
|
|
| 533 |
# Validate 'Answer' column in ground truth file
|
| 534 |
if 'Answer' not in ground_truth_df.columns:
|
| 535 |
return "Error: 'Answer' column is missing in the ground truth dataset.", load_leaderboard()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 536 |
merged_df = pd.merge(predictions_df, ground_truth_df, on='question_id', how='inner')
|
| 537 |
merged_df['pred_answer'] = merged_df['predicted_answer'].apply(clean_answer)
|
| 538 |
|
|
@@ -590,6 +605,22 @@ def evaluate_predictions_pro(prediction_file, model_name,Team_name ,add_to_leade
|
|
| 590 |
# Validate 'Answer' column in ground truth file
|
| 591 |
if 'Answer' not in ground_truth_df.columns:
|
| 592 |
return "Error: 'Answer' column is missing in the ground truth dataset.", load_leaderboard_pro()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 593 |
merged_df = pd.merge(predictions_df, ground_truth_df, on='question_id', how='inner')
|
| 594 |
merged_df['pred_answer'] = merged_df['predicted_answer'].apply(clean_answer)
|
| 595 |
|
|
|
|
| 533 |
# Validate 'Answer' column in ground truth file
|
| 534 |
if 'Answer' not in ground_truth_df.columns:
|
| 535 |
return "Error: 'Answer' column is missing in the ground truth dataset.", load_leaderboard()
|
| 536 |
+
|
| 537 |
+
|
| 538 |
+
|
| 539 |
+
# **Check if questions match**
|
| 540 |
+
pred_question_ids = set(predictions_df['question_id'])
|
| 541 |
+
gt_question_ids = set(ground_truth_df['question_id'])
|
| 542 |
+
|
| 543 |
+
missing_in_gt = pred_question_ids - gt_question_ids
|
| 544 |
+
missing_in_pred = gt_question_ids - pred_question_ids
|
| 545 |
+
|
| 546 |
+
if missing_in_gt:
|
| 547 |
+
return f"Error: Some question IDs in predictions are missing from the ground truth: {missing_in_gt}", load_leaderboard_pro()
|
| 548 |
+
if missing_in_pred:
|
| 549 |
+
return f"Warning: Some question IDs in ground truth are missing from the predictions: {missing_in_pred}", load_leaderboard_pro()
|
| 550 |
+
|
| 551 |
merged_df = pd.merge(predictions_df, ground_truth_df, on='question_id', how='inner')
|
| 552 |
merged_df['pred_answer'] = merged_df['predicted_answer'].apply(clean_answer)
|
| 553 |
|
|
|
|
| 605 |
# Validate 'Answer' column in ground truth file
|
| 606 |
if 'Answer' not in ground_truth_df.columns:
|
| 607 |
return "Error: 'Answer' column is missing in the ground truth dataset.", load_leaderboard_pro()
|
| 608 |
+
|
| 609 |
+
|
| 610 |
+
# **Check if questions match**
|
| 611 |
+
pred_question_ids = set(predictions_df['question_id'])
|
| 612 |
+
gt_question_ids = set(ground_truth_df['question_id'])
|
| 613 |
+
|
| 614 |
+
missing_in_gt = pred_question_ids - gt_question_ids
|
| 615 |
+
missing_in_pred = gt_question_ids - pred_question_ids
|
| 616 |
+
|
| 617 |
+
if missing_in_gt:
|
| 618 |
+
return f"Error: Some question IDs in predictions are missing from the ground truth: {missing_in_gt}", load_leaderboard_pro()
|
| 619 |
+
if missing_in_pred:
|
| 620 |
+
return f"Warning: Some question IDs in ground truth are missing from the predictions: {missing_in_pred}", load_leaderboard_pro()
|
| 621 |
+
|
| 622 |
+
# Merge and evaluate
|
| 623 |
+
|
| 624 |
merged_df = pd.merge(predictions_df, ground_truth_df, on='question_id', how='inner')
|
| 625 |
merged_df['pred_answer'] = merged_df['predicted_answer'].apply(clean_answer)
|
| 626 |
|