Spaces:
Running
Running
James McCool
commited on
Commit
·
1e0aade
1
Parent(s):
f23bbcc
Improve Kill, Death, and Assist Projection Scaling
Browse filesRefactor the projection calculation to:
- Introduce separate scaling factors for kills, deaths, and assists
- Ensure projections are scaled proportionally to match game predictions
- Maintain separate calculations for win and loss scenarios
- Improve accuracy of individual player stat projections
app.py
CHANGED
|
@@ -332,21 +332,27 @@ def init_team_data(game_count, team, opponent, win_loss_settings, kill_predictio
|
|
| 332 |
team_data = working_tables.drop_duplicates(subset = ['position'])
|
| 333 |
|
| 334 |
if win_loss_settings[game] == "Win":
|
| 335 |
-
|
| 336 |
-
|
| 337 |
-
# Calculate assists and scale them to not exceed total kills
|
| 338 |
raw_assists = team_data.apply(lambda row: row['wAssist%'] * opp_pos_assists_boost_win.get(row['position'], 1), axis=1) * kill_predictions[game]
|
|
|
|
|
|
|
| 339 |
assist_scale = min(1.0, kill_predictions[game] / raw_assists.sum()) if raw_assists.sum() > 0 else 1.0
|
|
|
|
|
|
|
| 340 |
team_data['Assist_Proj'] = raw_assists * assist_scale
|
| 341 |
|
| 342 |
team_data['CS_Proj'] = team_data.apply(lambda row: row['wCS'] * opp_pos_cs_boost_win.get(row['position'], 1), axis=1)
|
| 343 |
team_data = team_data[['playername', 'teamname', 'position', 'Kill_Proj', 'Death_Proj', 'Assist_Proj', 'CS_Proj']]
|
| 344 |
else:
|
| 345 |
-
|
| 346 |
-
|
| 347 |
-
# Calculate assists and scale them to not exceed total kills
|
| 348 |
raw_assists = team_data.apply(lambda row: row['lAssist%'] * opp_pos_assists_boost_loss.get(row['position'], 1), axis=1) * kill_predictions[game]
|
|
|
|
|
|
|
| 349 |
assist_scale = min(1.0, kill_predictions[game] / raw_assists.sum()) if raw_assists.sum() > 0 else 1.0
|
|
|
|
|
|
|
| 350 |
team_data['Assist_Proj'] = raw_assists * assist_scale
|
| 351 |
|
| 352 |
team_data['CS_Proj'] = team_data.apply(lambda row: row['lCS'] * opp_pos_cs_boost_loss.get(row['position'], 1), axis=1)
|
|
|
|
| 332 |
team_data = working_tables.drop_duplicates(subset = ['position'])
|
| 333 |
|
| 334 |
if win_loss_settings[game] == "Win":
|
| 335 |
+
raw_kills = team_data.apply(lambda row: row['wKill%'] * opp_pos_kills_boost_win.get(row['position'], 1), axis=1) * kill_predictions[game]
|
| 336 |
+
raw_deaths = team_data.apply(lambda row: row['wDeath%'] * opp_pos_deaths_boost_win.get(row['position'], 1), axis=1) * death_predictions[game]
|
|
|
|
| 337 |
raw_assists = team_data.apply(lambda row: row['wAssist%'] * opp_pos_assists_boost_win.get(row['position'], 1), axis=1) * kill_predictions[game]
|
| 338 |
+
kill_scale = min(1.0, kill_predictions[game] / raw_kills.sum()) if raw_kills.sum() > 0 else 1.0
|
| 339 |
+
death_scale = min(1.0, death_predictions[game] / raw_deaths.sum()) if raw_deaths.sum() > 0 else 1.0
|
| 340 |
assist_scale = min(1.0, kill_predictions[game] / raw_assists.sum()) if raw_assists.sum() > 0 else 1.0
|
| 341 |
+
team_data['Kill_Proj'] = raw_kills * kill_scale
|
| 342 |
+
team_data['Death_Proj'] = raw_deaths * death_scale
|
| 343 |
team_data['Assist_Proj'] = raw_assists * assist_scale
|
| 344 |
|
| 345 |
team_data['CS_Proj'] = team_data.apply(lambda row: row['wCS'] * opp_pos_cs_boost_win.get(row['position'], 1), axis=1)
|
| 346 |
team_data = team_data[['playername', 'teamname', 'position', 'Kill_Proj', 'Death_Proj', 'Assist_Proj', 'CS_Proj']]
|
| 347 |
else:
|
| 348 |
+
raw_kills = team_data.apply(lambda row: row['lKill%'] * opp_pos_kills_boost_loss.get(row['position'], 1), axis=1) * kill_predictions[game]
|
| 349 |
+
raw_deaths = team_data.apply(lambda row: row['lDeath%'] * opp_pos_deaths_boost_loss.get(row['position'], 1), axis=1) * death_predictions[game]
|
|
|
|
| 350 |
raw_assists = team_data.apply(lambda row: row['lAssist%'] * opp_pos_assists_boost_loss.get(row['position'], 1), axis=1) * kill_predictions[game]
|
| 351 |
+
kill_scale = min(1.0, kill_predictions[game] / raw_kills.sum()) if raw_kills.sum() > 0 else 1.0
|
| 352 |
+
death_scale = min(1.0, death_predictions[game] / raw_deaths.sum()) if raw_deaths.sum() > 0 else 1.0
|
| 353 |
assist_scale = min(1.0, kill_predictions[game] / raw_assists.sum()) if raw_assists.sum() > 0 else 1.0
|
| 354 |
+
team_data['Kill_Proj'] = raw_kills * kill_scale
|
| 355 |
+
team_data['Death_Proj'] = raw_deaths * death_scale
|
| 356 |
team_data['Assist_Proj'] = raw_assists * assist_scale
|
| 357 |
|
| 358 |
team_data['CS_Proj'] = team_data.apply(lambda row: row['lCS'] * opp_pos_cs_boost_loss.get(row['position'], 1), axis=1)
|