Spaces:
Sleeping
Sleeping
Commit
Β·
caf5910
1
Parent(s):
808ccfe
Enhanced admin panel
Browse files
README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
colorFrom: red
|
| 5 |
-
colorTo:
|
| 6 |
sdk: streamlit
|
| 7 |
sdk_version: 1.32.2
|
| 8 |
app_file: app.py
|
|
@@ -10,4 +10,48 @@ pinned: false
|
|
| 10 |
license: apache-2.0
|
| 11 |
---
|
| 12 |
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
title: DIS IPL Predictions
|
| 3 |
+
emoji: π¦
|
| 4 |
colorFrom: red
|
| 5 |
+
colorTo: pink
|
| 6 |
sdk: streamlit
|
| 7 |
sdk_version: 1.32.2
|
| 8 |
app_file: app.py
|
|
|
|
| 10 |
license: apache-2.0
|
| 11 |
---
|
| 12 |
|
| 13 |
+
# DIS IPL Match Predictions App
|
| 14 |
+
|
| 15 |
+
> "Predict, Compete, and Win π - Where Every Guess Counts! π"
|
| 16 |
+
|
| 17 |
+
Welcome to the DIS IPL Match Predictions App! This app allows you to predict the outcomes of IPL matches and compete with your colleagues to win exciting prizes.
|
| 18 |
+
|
| 19 |
+
## Getting Started
|
| 20 |
+
|
| 21 |
+
### Prerequisites
|
| 22 |
+
|
| 23 |
+
- Python 3.x installed on your system
|
| 24 |
+
- Git installed on your system
|
| 25 |
+
- Pip package manager
|
| 26 |
+
|
| 27 |
+
### Installation
|
| 28 |
+
|
| 29 |
+
1. Clone this repository to your local machine using Git:
|
| 30 |
+
|
| 31 |
+
```bash
|
| 32 |
+
git clone <repository_url>
|
| 33 |
+
```
|
| 34 |
+
|
| 35 |
+
2. Navigate to the cloned repository directory:
|
| 36 |
+
|
| 37 |
+
```bash
|
| 38 |
+
cd ipl-match-predictions-app
|
| 39 |
+
```
|
| 40 |
+
|
| 41 |
+
3. Install the required Python dependencies using Pip:
|
| 42 |
+
|
| 43 |
+
```bash
|
| 44 |
+
pip install -r requirements.txt
|
| 45 |
+
```
|
| 46 |
+
|
| 47 |
+
### Running The APP
|
| 48 |
+
|
| 49 |
+
1. After installing the dependencies, you can run the Streamlit app using the following command:
|
| 50 |
+
|
| 51 |
+
```bash
|
| 52 |
+
streamlit run app.py
|
| 53 |
+
```
|
| 54 |
+
|
| 55 |
+
2. The app will start running locally and open in your default web browser.
|
| 56 |
+
|
| 57 |
+
Thanks
|
app.py
CHANGED
|
@@ -11,6 +11,7 @@ import pytz
|
|
| 11 |
import streamlit as st
|
| 12 |
from datasets import load_dataset
|
| 13 |
from huggingface_hub import CommitScheduler, HfApi
|
|
|
|
| 14 |
|
| 15 |
# File paths as constants
|
| 16 |
PREDICTIONS_CSV = 'dis_predictions.csv'
|
|
@@ -348,8 +349,12 @@ with st.expander("Leaderboard π"):
|
|
| 348 |
ADMIN_PASSPHRASE = "admin123"
|
| 349 |
|
| 350 |
def fetch_latest_predictions(match_id):
|
| 351 |
-
dataset = load_dataset("Jay-Rajput/DIS_IPL_Dataset",
|
| 352 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 353 |
return predictions
|
| 354 |
|
| 355 |
|
|
@@ -364,8 +369,8 @@ def update_leaderboard_and_outcomes(match_id, winning_team, man_of_the_match):
|
|
| 364 |
|
| 365 |
outcomes = load_data(OUTCOMES_JSON) # Load existing match outcomes
|
| 366 |
# Load existing match outcomes and user data from the test split
|
| 367 |
-
dataset = load_dataset("Jay-Rajput/DIS_IPL_Dataset",
|
| 368 |
-
users =
|
| 369 |
|
| 370 |
# Directly update or add the match outcome
|
| 371 |
outcome_exists = False
|
|
@@ -378,23 +383,26 @@ def update_leaderboard_and_outcomes(match_id, winning_team, man_of_the_match):
|
|
| 378 |
outcomes.append({"match_id": match_id, "winning_team": winning_team, "man_of_the_match": man_of_the_match})
|
| 379 |
|
| 380 |
# Update user points based on prediction accuracy
|
| 381 |
-
for prediction in predictions:
|
| 382 |
user_name = prediction['user_name']
|
| 383 |
-
|
| 384 |
-
|
| 385 |
-
|
| 386 |
|
| 387 |
# Update points based on prediction accuracy
|
| 388 |
-
if
|
| 389 |
users[user_name] += 1000
|
| 390 |
-
users[user_name] +=
|
| 391 |
-
if
|
| 392 |
users[user_name] += 400 # Bonus for both correct predictions
|
| 393 |
else:
|
| 394 |
-
users[user_name] -= 200 +
|
| 395 |
|
| 396 |
save_match_outcomes(outcomes)
|
| 397 |
users.save_to_disk(USERS_JSON)
|
|
|
|
|
|
|
|
|
|
| 398 |
|
| 399 |
|
| 400 |
with st.sidebar:
|
|
|
|
| 11 |
import streamlit as st
|
| 12 |
from datasets import load_dataset
|
| 13 |
from huggingface_hub import CommitScheduler, HfApi
|
| 14 |
+
from datasets import Dataset
|
| 15 |
|
| 16 |
# File paths as constants
|
| 17 |
PREDICTIONS_CSV = 'dis_predictions.csv'
|
|
|
|
| 349 |
ADMIN_PASSPHRASE = "admin123"
|
| 350 |
|
| 351 |
def fetch_latest_predictions(match_id):
|
| 352 |
+
dataset = load_dataset("Jay-Rajput/DIS_IPL_Dataset", name="predictions")
|
| 353 |
+
# Convert to pandas DataFrame
|
| 354 |
+
df = dataset.to_pandas()
|
| 355 |
+
# Remove duplicate rows
|
| 356 |
+
df_unique = df.drop_duplicates(subset=['user_name'])
|
| 357 |
+
predictions = df_unique['train'].filter(lambda example: example['match_id'] == match_id)
|
| 358 |
return predictions
|
| 359 |
|
| 360 |
|
|
|
|
| 369 |
|
| 370 |
outcomes = load_data(OUTCOMES_JSON) # Load existing match outcomes
|
| 371 |
# Load existing match outcomes and user data from the test split
|
| 372 |
+
dataset = load_dataset("Jay-Rajput/DIS_IPL_Dataset", name="leaders")
|
| 373 |
+
users = dataset.to_pandas()
|
| 374 |
|
| 375 |
# Directly update or add the match outcome
|
| 376 |
outcome_exists = False
|
|
|
|
| 383 |
outcomes.append({"match_id": match_id, "winning_team": winning_team, "man_of_the_match": man_of_the_match})
|
| 384 |
|
| 385 |
# Update user points based on prediction accuracy
|
| 386 |
+
for index, prediction in predictions.iterrows():
|
| 387 |
user_name = prediction['user_name']
|
| 388 |
+
predicted_winner = prediction['predicted_winner']
|
| 389 |
+
predicted_motm = prediction['predicted_motm']
|
| 390 |
+
bid_points = prediction['bid_points']
|
| 391 |
|
| 392 |
# Update points based on prediction accuracy
|
| 393 |
+
if predicted_winner == winning_team:
|
| 394 |
users[user_name] += 1000
|
| 395 |
+
users[user_name] += bid_points
|
| 396 |
+
if predicted_motm == man_of_the_match:
|
| 397 |
users[user_name] += 400 # Bonus for both correct predictions
|
| 398 |
else:
|
| 399 |
+
users[user_name] -= 200 + bid_points # Penalty for wrong team prediction
|
| 400 |
|
| 401 |
save_match_outcomes(outcomes)
|
| 402 |
users.save_to_disk(USERS_JSON)
|
| 403 |
+
# Convert the updated DataFrame back to a Hugging Face Dataset and push updates
|
| 404 |
+
updated_dataset = Dataset.from_pandas(users)
|
| 405 |
+
updated_dataset.push_to_hub("Jay-Rajput/DIS_IPL_Dataset")
|
| 406 |
|
| 407 |
|
| 408 |
with st.sidebar:
|