Spaces:
Sleeping
Sleeping
jarajpu
commited on
Commit
·
d724e2b
1
Parent(s):
cf0b0bc
enhanced leaderboard
Browse files
app.py
CHANGED
|
@@ -399,6 +399,8 @@ def update_leaderboard_and_outcomes(match_id, winning_team, man_of_the_match):
|
|
| 399 |
|
| 400 |
# Load existing match outcomes and user data from the test split
|
| 401 |
users = load_dataset("Jay-Rajput/DIS_IPL_Leads", split="train")
|
|
|
|
|
|
|
| 402 |
|
| 403 |
# Directly update or add the match outcome
|
| 404 |
outcome_exists = False
|
|
@@ -418,19 +420,22 @@ def update_leaderboard_and_outcomes(match_id, winning_team, man_of_the_match):
|
|
| 418 |
bid_points = prediction['bid_points']
|
| 419 |
|
| 420 |
# Update points based on prediction accuracy
|
|
|
|
| 421 |
if predicted_winner == winning_team:
|
| 422 |
-
|
| 423 |
-
users[user_name][0]['0'] += bid_points
|
| 424 |
if predicted_motm == man_of_the_match:
|
| 425 |
-
|
| 426 |
else:
|
| 427 |
-
|
|
|
|
|
|
|
|
|
|
| 428 |
|
| 429 |
users.to_json(USERS_JSON)
|
| 430 |
outcomes.to_json(OUTCOMES)
|
| 431 |
# Convert the updated DataFrame back to a Hugging Face Dataset and push updates
|
| 432 |
-
|
| 433 |
-
|
| 434 |
outcomes.push_to_hub("Jay-Rajput/DIS_IPL_Outcomes", split="train")
|
| 435 |
|
| 436 |
|
|
|
|
| 399 |
|
| 400 |
# Load existing match outcomes and user data from the test split
|
| 401 |
users = load_dataset("Jay-Rajput/DIS_IPL_Leads", split="train")
|
| 402 |
+
# Convert users dataset to pandas DataFrame
|
| 403 |
+
users_df = pd.DataFrame(users)
|
| 404 |
|
| 405 |
# Directly update or add the match outcome
|
| 406 |
outcome_exists = False
|
|
|
|
| 420 |
bid_points = prediction['bid_points']
|
| 421 |
|
| 422 |
# Update points based on prediction accuracy
|
| 423 |
+
points = users_df[user_name][0]['0']
|
| 424 |
if predicted_winner == winning_team:
|
| 425 |
+
points += 1000 + bid_points
|
|
|
|
| 426 |
if predicted_motm == man_of_the_match:
|
| 427 |
+
points += 400
|
| 428 |
else:
|
| 429 |
+
points -= 200 + bid_points
|
| 430 |
+
|
| 431 |
+
# Update user's points in the DataFrame
|
| 432 |
+
users_df[user_name][0]['0'] = points
|
| 433 |
|
| 434 |
users.to_json(USERS_JSON)
|
| 435 |
outcomes.to_json(OUTCOMES)
|
| 436 |
# Convert the updated DataFrame back to a Hugging Face Dataset and push updates
|
| 437 |
+
updated_dataset = Dataset.from_pandas(users_df)
|
| 438 |
+
updated_dataset.push_to_hub("Jay-Rajput/DIS_IPL_Leads", split="train")
|
| 439 |
outcomes.push_to_hub("Jay-Rajput/DIS_IPL_Outcomes", split="train")
|
| 440 |
|
| 441 |
|