Spaces:
Sleeping
Sleeping
Commit
·
05c0779
1
Parent(s):
01b897e
Allowing 0 bid points
Browse files- app.py +4 -19
- dis_predictions.csv +0 -11
- predictions.csv +0 -33
app.py
CHANGED
|
@@ -12,7 +12,6 @@ from datasets import Dataset, load_dataset
|
|
| 12 |
from huggingface_hub import CommitScheduler
|
| 13 |
|
| 14 |
# File paths as constants
|
| 15 |
-
PREDICTIONS_CSV = 'dis_predictions.csv'
|
| 16 |
USERS_JSON = 'leaders/users.json'
|
| 17 |
MATCHES_JSON = 'matches.json'
|
| 18 |
OUTCOMES_JSON = 'match_outcomes.json'
|
|
@@ -60,16 +59,6 @@ scheduler = CommitScheduler(
|
|
| 60 |
)
|
| 61 |
|
| 62 |
|
| 63 |
-
# Initialize CSV and JSON files if they don't exist
|
| 64 |
-
def initialize_files():
|
| 65 |
-
# Initialize predictions CSV
|
| 66 |
-
try:
|
| 67 |
-
pd.read_csv(PREDICTIONS_CSV)
|
| 68 |
-
except FileNotFoundError:
|
| 69 |
-
df = pd.DataFrame(columns=['user_name', 'match_id', 'predicted_winner', 'predicted_motm', 'bid_points'])
|
| 70 |
-
df.to_csv(PREDICTIONS_CSV, index=False)
|
| 71 |
-
|
| 72 |
-
|
| 73 |
def load_data(file_path):
|
| 74 |
"""
|
| 75 |
Load data from a JSON or CSV file.
|
|
@@ -136,13 +125,6 @@ def is_submission_allowed(match_id):
|
|
| 136 |
return False # If match_id not found, default to False
|
| 137 |
|
| 138 |
|
| 139 |
-
def load_predictions(PREDICTIONS_CSV):
|
| 140 |
-
try:
|
| 141 |
-
return pd.read_csv(PREDICTIONS_CSV)
|
| 142 |
-
except FileNotFoundError:
|
| 143 |
-
return pd.DataFrame()
|
| 144 |
-
|
| 145 |
-
|
| 146 |
# Submit prediction function
|
| 147 |
def submit_prediction(
|
| 148 |
user_name,
|
|
@@ -259,7 +241,7 @@ def user_selection_and_prediction():
|
|
| 259 |
players = player_list[predicted_winner]
|
| 260 |
predicted_motm = st.selectbox("Predicted Man of the Match", players)
|
| 261 |
|
| 262 |
-
bid_points = st.number_input("Bid Points", min_value=
|
| 263 |
|
| 264 |
if st.button("Submit Prediction"):
|
| 265 |
submit_prediction(user_name, match_id, predicted_winner, predicted_motm, bid_points, max_bid_points)
|
|
@@ -466,6 +448,9 @@ def update_leaderboard_and_outcomes(match_id, winning_team, man_of_the_match, ou
|
|
| 466 |
else:
|
| 467 |
# Deduct 1000 points for not submitting a prediction
|
| 468 |
user_points -= 1000
|
|
|
|
|
|
|
|
|
|
| 469 |
|
| 470 |
# Update user's points in the DataFrame
|
| 471 |
users_df[user_name][0]['0'] = user_points
|
|
|
|
| 12 |
from huggingface_hub import CommitScheduler
|
| 13 |
|
| 14 |
# File paths as constants
|
|
|
|
| 15 |
USERS_JSON = 'leaders/users.json'
|
| 16 |
MATCHES_JSON = 'matches.json'
|
| 17 |
OUTCOMES_JSON = 'match_outcomes.json'
|
|
|
|
| 59 |
)
|
| 60 |
|
| 61 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
def load_data(file_path):
|
| 63 |
"""
|
| 64 |
Load data from a JSON or CSV file.
|
|
|
|
| 125 |
return False # If match_id not found, default to False
|
| 126 |
|
| 127 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
# Submit prediction function
|
| 129 |
def submit_prediction(
|
| 130 |
user_name,
|
|
|
|
| 241 |
players = player_list[predicted_winner]
|
| 242 |
predicted_motm = st.selectbox("Predicted Man of the Match", players)
|
| 243 |
|
| 244 |
+
bid_points = st.number_input("Bid Points", min_value=0, value=100, format="%d")
|
| 245 |
|
| 246 |
if st.button("Submit Prediction"):
|
| 247 |
submit_prediction(user_name, match_id, predicted_winner, predicted_motm, bid_points, max_bid_points)
|
|
|
|
| 448 |
else:
|
| 449 |
# Deduct 1000 points for not submitting a prediction
|
| 450 |
user_points -= 1000
|
| 451 |
+
|
| 452 |
+
if user_points < 0:
|
| 453 |
+
user_points = 0
|
| 454 |
|
| 455 |
# Update user's points in the DataFrame
|
| 456 |
users_df[user_name][0]['0'] = user_points
|
dis_predictions.csv
DELETED
|
@@ -1,11 +0,0 @@
|
|
| 1 |
-
user_name,match_id,predicted_winner,predicted_motm,bid_points
|
| 2 |
-
Sunil,20240325_6,RCB,Glenn Maxwell,900
|
| 3 |
-
Sahil,20240325_6,RCB,Virat Kohli,350
|
| 4 |
-
Vinay,20240325_6,RCB,Faf du Plessis,200
|
| 5 |
-
Megha,20240325_6,RCB,Virat Kohli,500
|
| 6 |
-
Jay,20240325_6,RCB,Virat Kohli,200
|
| 7 |
-
Sai,20240325_6,RCB,Glenn Maxwell,620
|
| 8 |
-
Haaris,20240325_6,RCB,Virat Kohli,1200
|
| 9 |
-
Naveein,20240325_6,RCB,Faf du Plessis,500
|
| 10 |
-
Praveen,20240325_6,RCB,Faf du Plessis,1800
|
| 11 |
-
Kishore,20240325_6,RCB,Glenn Maxwell,500
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
predictions.csv
DELETED
|
@@ -1,33 +0,0 @@
|
|
| 1 |
-
user_name,match_id,predicted_winner,predicted_motm,bid_points
|
| 2 |
-
Sahil,20240322_1,CSK,Ruturaj Gaikwad,250
|
| 3 |
-
Naveein,20240322_1,CSK,Rachin Ravindra,1000
|
| 4 |
-
Ganesh,20240322_1,CSK,Ruturaj Gaikwad,300
|
| 5 |
-
Jay,20240322_1,CSK,Ruturaj Gaikwad,500
|
| 6 |
-
Megha,20240322_1,RCB,Virat Kohli,500
|
| 7 |
-
Arpit,20240322_1,CSK,Ravindra Jadeja,1000
|
| 8 |
-
Sunil,20240322_1,RCB,Virat Kohli,299
|
| 9 |
-
Praveen,20240322_1,CSK,Ravindra Jadeja,1000
|
| 10 |
-
Vinay,20240322_1,CSK,Rachin Ravindra,216
|
| 11 |
-
Kichu,20240322_1,CSK,MS Dhoni,500
|
| 12 |
-
Haaris,20240322_1,CSK,MS Dhoni,500
|
| 13 |
-
Rakesh,20240322_1,CSK,MS Dhoni,500
|
| 14 |
-
Megha,20240323_2,DC,Rishabh Pant,200
|
| 15 |
-
Arpit,20240323_2,DC,David Warner,500
|
| 16 |
-
Sahil,20240323_2,DC,Mitchell Marsh,250
|
| 17 |
-
Sai,20240323_2,DC,Rishabh Pant,200
|
| 18 |
-
Neha,20240323_2,DC,Rishabh Pant,500
|
| 19 |
-
Ganesh,20240323_2,DC,Axar Patel,350
|
| 20 |
-
Vinay,20240323_2,DC,David Warner,516
|
| 21 |
-
Megha,20240323_3,KKR,Rinku Singh,200
|
| 22 |
-
Arpit,20240323_3,KKR,Andre Russell,500
|
| 23 |
-
Sahil,20240323_3,KKR,Phil Salt,350
|
| 24 |
-
Sai,20240323_3,SRH,Pat Cummins,300
|
| 25 |
-
Naveein,20240323_3,SRH,Travis Head,500
|
| 26 |
-
Haaris,20240323_3,SRH,Travis Head,300
|
| 27 |
-
Vaibhav,20240323_3,KKR,Mitchell Starc,300
|
| 28 |
-
Neha,20240323_3,KKR,Rinku Singh,300
|
| 29 |
-
Vinay,20240323_3,SRH,Pat Cummins,100
|
| 30 |
-
Sunil,20240325_6,RCB,Glenn Maxwell,900
|
| 31 |
-
Sahil,20240325_6,RCB,Virat Kohli,350
|
| 32 |
-
Vinay,20240325_6,RCB,Faf du Plessis,200
|
| 33 |
-
Megha,20240325_6,RCB,Virat Kohli,500
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|