Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,9 +6,11 @@ import gradio as gr
|
|
| 6 |
|
| 7 |
# === Milestone thresholds ===
|
| 8 |
milestones = {
|
| 9 |
-
"points": [10, 12, 15, 18, 20, 25, 30, 35, 40, 45, 50],
|
| 10 |
"rebounds": [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],
|
| 11 |
-
"assists": [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
|
|
|
|
|
|
|
| 12 |
}
|
| 13 |
|
| 14 |
# === Helper Functions ===
|
|
@@ -113,8 +115,10 @@ def load_and_prepare_data(proj_file, log_file, apply_filter, threshold):
|
|
| 113 |
"points": pdata['points'].mean(),
|
| 114 |
"rebounds": pdata['rebounds'].mean(),
|
| 115 |
"assists": pdata['assists'].mean(),
|
|
|
|
|
|
|
| 116 |
}
|
| 117 |
-
for stat in ['points', 'rebounds', 'assists']:
|
| 118 |
raw_data = pdata[stat]
|
| 119 |
weights = determine_best_fit(raw_data)
|
| 120 |
row[f"Poisson_Weight_{stat}"] = round(weights["Poisson"], 4)
|
|
@@ -275,7 +279,7 @@ with gr.Blocks(title="🏀 Player Milestone Estimator", css=".green-button {back
|
|
| 275 |
outlier_threshold_input = gr.Slider(label="Minutes Deviation Threshold (%)", minimum=0, maximum=2.0, value=0.9, step=0.01)
|
| 276 |
|
| 277 |
player_dropdown = gr.Dropdown(label="Select a Player", interactive=True)
|
| 278 |
-
stat_dropdown = gr.Dropdown(["points", "rebounds", "assists"], label=" Select a Stat")
|
| 279 |
|
| 280 |
# File and filter logic triggers
|
| 281 |
proj_file.change(load_and_prepare_data, [proj_file, log_file, outlier_filter_toggle, outlier_threshold_input], player_dropdown)
|
|
@@ -315,7 +319,7 @@ with gr.Blocks(title="🏀 Player Milestone Estimator", css=".green-button {back
|
|
| 315 |
recent_games = temp_df[temp_df['player'] == player].copy()
|
| 316 |
recent_games['game_date_pacific'] = pd.to_datetime(recent_games['game_date_pacific'])
|
| 317 |
recent_games = recent_games.sort_values(by='game_date_pacific', ascending=False).head(10)
|
| 318 |
-
recent_games_display = recent_games[['game_date_pacific', 'projected_opponent', 'points', 'rebounds', 'assists', 'minutes_played', 'is_minutes_outlier']].rename(
|
| 319 |
columns={
|
| 320 |
"game_date_pacific": "Date",
|
| 321 |
"projected_opponent": "Opp"
|
|
|
|
| 6 |
|
| 7 |
# === Milestone thresholds ===
|
| 8 |
milestones = {
|
| 9 |
+
"points": [8, 10, 12, 15, 18, 20, 25, 30, 35, 40, 45, 50],
|
| 10 |
"rebounds": [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],
|
| 11 |
+
"assists": [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],
|
| 12 |
+
"steals": [1, 2, 3, 4, 5],
|
| 13 |
+
"blocks": [1, 2, 3, 4, 5]
|
| 14 |
}
|
| 15 |
|
| 16 |
# === Helper Functions ===
|
|
|
|
| 115 |
"points": pdata['points'].mean(),
|
| 116 |
"rebounds": pdata['rebounds'].mean(),
|
| 117 |
"assists": pdata['assists'].mean(),
|
| 118 |
+
"steals": pdata['steals'].mean(),
|
| 119 |
+
"blocks": pdata['blocks'].mean()
|
| 120 |
}
|
| 121 |
+
for stat in ['points', 'rebounds', 'assists', 'steals', 'blocks']:
|
| 122 |
raw_data = pdata[stat]
|
| 123 |
weights = determine_best_fit(raw_data)
|
| 124 |
row[f"Poisson_Weight_{stat}"] = round(weights["Poisson"], 4)
|
|
|
|
| 279 |
outlier_threshold_input = gr.Slider(label="Minutes Deviation Threshold (%)", minimum=0, maximum=2.0, value=0.9, step=0.01)
|
| 280 |
|
| 281 |
player_dropdown = gr.Dropdown(label="Select a Player", interactive=True)
|
| 282 |
+
stat_dropdown = gr.Dropdown(["points", "rebounds", "assists", "steals", "blocks"], label=" Select a Stat")
|
| 283 |
|
| 284 |
# File and filter logic triggers
|
| 285 |
proj_file.change(load_and_prepare_data, [proj_file, log_file, outlier_filter_toggle, outlier_threshold_input], player_dropdown)
|
|
|
|
| 319 |
recent_games = temp_df[temp_df['player'] == player].copy()
|
| 320 |
recent_games['game_date_pacific'] = pd.to_datetime(recent_games['game_date_pacific'])
|
| 321 |
recent_games = recent_games.sort_values(by='game_date_pacific', ascending=False).head(10)
|
| 322 |
+
recent_games_display = recent_games[['game_date_pacific', 'projected_opponent', 'points', 'rebounds', 'assists', 'steals', 'blocks', 'minutes_played', 'is_minutes_outlier']].rename(
|
| 323 |
columns={
|
| 324 |
"game_date_pacific": "Date",
|
| 325 |
"projected_opponent": "Opp"
|