SondosMB commited on
Commit
15fabfc
·
verified ·
1 Parent(s): 6c03d0d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -15
app.py CHANGED
@@ -536,17 +536,17 @@ def evaluate_predictions(prediction_file, model_name,Team_name ,add_to_leaderboa
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)
@@ -607,18 +607,17 @@ def evaluate_predictions_pro(prediction_file, model_name,Team_name ,add_to_leade
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')
 
536
 
537
 
538
 
539
+ # Convert to sets for comparison
540
  pred_question_ids = set(predictions_df['question_id'])
541
  gt_question_ids = set(ground_truth_df['question_id'])
542
 
543
+ # Check if all ground truth questions are in predictions
544
+ if gt_question_ids != pred_question_ids:
545
+ return "Error: Prediction file does not contain all question IDs from the ground truth.", load_leaderboard()
546
 
547
+ # Check if the order of question IDs is the same
548
+ if not (ground_truth_df['question_id'].tolist() == predictions_df['question_id'].tolist()):
549
+ return "Error: The order of question IDs in the prediction file does not match the ground truth.", load_leaderboard()
 
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)
 
607
  return "Error: 'Answer' column is missing in the ground truth dataset.", load_leaderboard_pro()
608
 
609
 
610
+ # Convert to sets for comparison
611
  pred_question_ids = set(predictions_df['question_id'])
612
  gt_question_ids = set(ground_truth_df['question_id'])
613
 
614
+ # Check if all ground truth questions are in predictions
615
+ if gt_question_ids != pred_question_ids:
616
+ return "Error: Prediction file does not contain all question IDs from the ground truth.", load_leaderboard_pro()
 
 
 
 
617
 
618
+ # Check if the order of question IDs is the same
619
+ if not (ground_truth_df['question_id'].tolist() == predictions_df['question_id'].tolist()):
620
+ return "Error: The order of question IDs in the prediction file does not match the ground truth.", load_leaderboard_pro()
621
  # Merge and evaluate
622
 
623
  merged_df = pd.merge(predictions_df, ground_truth_df, on='question_id', how='inner')