Spaces:
Sleeping
Sleeping
Commit ·
0c2fdb7
1
Parent(s): dfbf309
Enhanced admin panel
Browse files123456781 unmodified line10111213---title: Testingemoji: 📈colorFrom: redcolorTo: redsdk: streamlitsdk_version: 1.32.2app_file: app.py1 unmodified linelicense: apache-2.0---Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference123456781 unmodified line101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657---title: DIS IPL Predictionsemoji: 🦀colorFrom: redcolorTo: pinksdk: streamlitsdk_version: 1.32.2app_file: app.py1 unmodified linelicense: apache-2.0---# DIS IPL Match Predictions App> "Predict, Compete, and Win 🏏 - Where Every Guess Counts! 🏆"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.## Getting Started### Prerequisites- Python 3.x installed on your system- Git installed on your system- Pip package manager### Installation1. Clone this repository to your local machine using Git:```bashgit clone <repository_url>```2. Navigate to the cloned repository directory:```bashcd ipl-match-predictions-app```3. Install the required Python dependencies using Pip:```bashpip install -r requirements.txt```### Running The APP1. After installing the dependencies, you can run the Streamlit app using the following command:```bashstreamlit run app.py```2. The app will start running locally and open in your default web browser.Thanks
10 unmodified lines111213141516331 unmodified lines3483493503513523533543558 unmodified lines3643653663673683693703716 unmodified lines37837938038138238338438538638738838939039139239339439539639739839940010 unmodified linesimport streamlit as stfrom datasets import load_datasetfrom huggingface_hub import CommitScheduler, HfApi# File paths as constantsPREDICTIONS_CSV = 'dis_predictions.csv'331 unmodified linesADMIN_PASSPHRASE = "admin123"def fetch_latest_predictions(match_id):dataset = load_dataset("Jay-Rajput/DIS_IPL_Dataset", config_name="predictions")predictions = dataset['train'].filter(lambda example: example['match_id'] == match_id)return predictions8 unmodified linesoutcomes = load_data(OUTCOMES_JSON) # Load existing match outcomes# Load existing match outcomes and user data from the test splitdataset = load_dataset("Jay-Rajput/DIS_IPL_Dataset", config_name="leaders")users = {item['user_name']: item for item in dataset['train']}# Directly update or add the match outcomeoutcome_exists = False6 unmodified linesoutcomes.append({"match_id": match_id, "winning_team": winning_team, "man_of_the_match": man_of_the_match})# Update user points based on prediction accuracyfor prediction in predictions:user_name = prediction['user_name']# Initialize user points if not presentif user_name not in users:users[user_name] = {'user_name': user_name, 'points': 0}# Update points based on prediction accuracyif prediction['predicted_winner'] == winning_team:users[user_name] += 1000users[user_name] += prediction['bid_points']if prediction['predicted_motm'] == man_of_the_match:users[user_name] += 400 # Bonus for both correct predictionselse:users[user_name] -= 200 + prediction['bid_points'] # Penalty for wrong team predictionsave_match_outcomes(outcomes)users.save_to_disk(USERS_JSON)with st.sidebar:10 unmodified lines11121314151617331 unmodified lines3493503513523533543553563573583593608 unmodified lines3693703713723733743753766 unmodified lines38338438538638738838939039139239339439539639739839940040140240340440540640740810 unmodified linesimport streamlit as stfrom datasets import load_datasetfrom huggingface_hub import CommitScheduler, HfApifrom datasets import Dataset# File paths as constantsPREDICTIONS_CSV = 'dis_predictions.csv'331 unmodified linesADMIN_PASSPHRASE = "admin123"def fetch_latest_predictions(match_id):dataset = load_dataset("Jay-Rajput/DIS_IPL_Dataset", name="predictions")# Convert to pandas DataFramedf = dataset.to_pandas()# Remove duplicate rowsdf_unique = df.drop_duplicates(subset=['user_name'])predictions = df_unique['train'].filter(lambda example: example['match_id'] == match_id)return predictions8 unmodified linesoutcomes = load_data(OUTCOMES_JSON) # Load existing match outcomes# Load existing match outcomes and user data from the test splitdataset = load_dataset("Jay-Rajput/DIS_IPL_Dataset", name="leaders")users = dataset.to_pandas()# Directly update or add the match outcomeoutcome_exists = False6 unmodified linesoutcomes.append({"match_id": match_id, "winning_team": winning_team, "man_of_the_match": man_of_the_match})# Update user points based on prediction accuracyfor index, prediction in predictions.iterrows():user_name = prediction['user_name']predicted_winner = prediction['predicted_winner']predicted_motm = prediction['predicted_motm']bid_points = prediction['bid_points']# Update points based on prediction accuracyif predicted_winner == winning_team:users[user_name] += 1000users[user_name] += bid_pointsif predicted_motm == man_of_the_match:users[user_name] += 400 # Bonus for both correct predictionselse:users[user_name] -= 200 + bid_points # Penalty for wrong team predictionsave_match_outcomes(outcomes)users.save_to_disk(USERS_JSON)# Convert the updated DataFrame back to a Hugging Face Dataset and push updatesupdated_dataset = Dataset.from_pandas(users)updated_dataset.push_to_hub("Jay-Rajput/DIS_IPL_Dataset")with st.sidebar:
README.md+48-4
app.py+20-12