Spaces:
Running
Running
James McCool
commited on
Commit
·
ceb105f
1
Parent(s):
5b0cc81
Refactor assist projection calculations in app.py to ensure they do not exceed total kills. Introduced scaling for assist projections based on raw assist calculations, improving accuracy in player performance metrics. Additionally, added duplicate removal based on 'position' to enhance data integrity in team data initialization.
Browse files
app.py
CHANGED
@@ -324,17 +324,26 @@ def init_team_data(team, opponent, win_loss_settings, kill_predictions, death_pr
|
|
324 |
'playername_avg_total_cs_win': 'wCS', 'playername_avg_kill_share_loss': 'lKill%', 'playername_avg_death_share_loss': 'lDeath%',
|
325 |
'playername_avg_assist_share_loss': 'lAssist%', 'playername_avg_total_cs_loss': 'lCS'})
|
326 |
team_data = working_tables.drop_duplicates(subset = ['playername'])
|
|
|
327 |
|
328 |
if win_loss_settings[game] == "Win":
|
329 |
team_data['Kill_Proj'] = team_data.apply(lambda row: row['wKill%'] * opp_pos_kills_boost_win.get(row['position'], 1), axis=1) * kill_predictions[game]
|
330 |
team_data['Death_Proj'] = team_data.apply(lambda row: row['wDeath%'] * opp_pos_deaths_boost_win.get(row['position'], 1), axis=1) * death_predictions[game]
|
331 |
-
|
|
|
|
|
|
|
|
|
332 |
team_data['CS_Proj'] = team_data.apply(lambda row: row['wCS'] * opp_pos_cs_boost_win.get(row['position'], 1), axis=1)
|
333 |
team_data = team_data[['playername', 'teamname', 'position', 'Kill_Proj', 'Death_Proj', 'Assist_Proj', 'CS_Proj']]
|
334 |
else:
|
335 |
team_data['Kill_Proj'] = team_data.apply(lambda row: row['lKill%'] * opp_pos_kills_boost_loss.get(row['position'], 1), axis=1) * kill_predictions[game]
|
336 |
team_data['Death_Proj'] = team_data.apply(lambda row: row['lDeath%'] * opp_pos_deaths_boost_loss.get(row['position'], 1), axis=1) * death_predictions[game]
|
337 |
-
|
|
|
|
|
|
|
|
|
338 |
team_data['CS_Proj'] = team_data.apply(lambda row: row['lCS'] * opp_pos_cs_boost_loss.get(row['position'], 1), axis=1)
|
339 |
team_data = team_data[['playername', 'teamname', 'position', 'Kill_Proj', 'Death_Proj', 'Assist_Proj', 'CS_Proj']]
|
340 |
else:
|
@@ -344,6 +353,7 @@ def init_team_data(team, opponent, win_loss_settings, kill_predictions, death_pr
|
|
344 |
'playername_avg_total_cs_win': 'wCS', 'playername_avg_kills_loss': 'lKill%', 'playername_avg_deaths_loss': 'lDeath%',
|
345 |
'playername_avg_assists_loss': 'lAssist%', 'playername_avg_total_cs_loss': 'lCS'})
|
346 |
team_data = working_tables.drop_duplicates(subset = ['playername'])
|
|
|
347 |
|
348 |
if win_loss_settings[game] == "Win":
|
349 |
team_data['Kill_Proj'] = team_data.apply(lambda row: row['wKill%'] * opp_pos_kills_boost_win.get(row['position'], 1), axis=1)
|
@@ -530,13 +540,21 @@ def init_player_data(players, opponent, win_loss_settings, kill_predictions, dea
|
|
530 |
if win_loss_settings[game] == "Win":
|
531 |
team_data['Kill_Proj'] = team_data.apply(lambda row: row['wKill%'] * opp_pos_kills_boost_win.get(row['position'], 1), axis=1) * kill_predictions[game]
|
532 |
team_data['Death_Proj'] = team_data.apply(lambda row: row['wDeath%'] * opp_pos_deaths_boost_win.get(row['position'], 1), axis=1) * death_predictions[game]
|
533 |
-
|
|
|
|
|
|
|
|
|
534 |
team_data['CS_Proj'] = team_data.apply(lambda row: row['wCS'] * opp_pos_cs_boost_win.get(row['position'], 1), axis=1)
|
535 |
team_data = team_data[['playername', 'teamname', 'position', 'Kill_Proj', 'Death_Proj', 'Assist_Proj', 'CS_Proj']]
|
536 |
else:
|
537 |
team_data['Kill_Proj'] = team_data.apply(lambda row: row['lKill%'] * opp_pos_kills_boost_loss.get(row['position'], 1), axis=1) * kill_predictions[game]
|
538 |
team_data['Death_Proj'] = team_data.apply(lambda row: row['lDeath%'] * opp_pos_deaths_boost_loss.get(row['position'], 1), axis=1) * death_predictions[game]
|
539 |
-
|
|
|
|
|
|
|
|
|
540 |
team_data['CS_Proj'] = team_data.apply(lambda row: row['lCS'] * opp_pos_cs_boost_loss.get(row['position'], 1), axis=1)
|
541 |
team_data = team_data[['playername', 'teamname', 'position', 'Kill_Proj', 'Death_Proj', 'Assist_Proj', 'CS_Proj']]
|
542 |
else:
|
|
|
324 |
'playername_avg_total_cs_win': 'wCS', 'playername_avg_kill_share_loss': 'lKill%', 'playername_avg_death_share_loss': 'lDeath%',
|
325 |
'playername_avg_assist_share_loss': 'lAssist%', 'playername_avg_total_cs_loss': 'lCS'})
|
326 |
team_data = working_tables.drop_duplicates(subset = ['playername'])
|
327 |
+
team_data = working_tables.drop_duplicates(subset = ['position'])
|
328 |
|
329 |
if win_loss_settings[game] == "Win":
|
330 |
team_data['Kill_Proj'] = team_data.apply(lambda row: row['wKill%'] * opp_pos_kills_boost_win.get(row['position'], 1), axis=1) * kill_predictions[game]
|
331 |
team_data['Death_Proj'] = team_data.apply(lambda row: row['wDeath%'] * opp_pos_deaths_boost_win.get(row['position'], 1), axis=1) * death_predictions[game]
|
332 |
+
# Calculate assists and scale them to not exceed total kills
|
333 |
+
raw_assists = team_data.apply(lambda row: row['wAssist%'] * opp_pos_assists_boost_win.get(row['position'], 1), axis=1) * kill_predictions[game]
|
334 |
+
assist_scale = min(1.0, kill_predictions[game] / raw_assists.sum()) if raw_assists.sum() > 0 else 1.0
|
335 |
+
team_data['Assist_Proj'] = raw_assists * assist_scale
|
336 |
+
|
337 |
team_data['CS_Proj'] = team_data.apply(lambda row: row['wCS'] * opp_pos_cs_boost_win.get(row['position'], 1), axis=1)
|
338 |
team_data = team_data[['playername', 'teamname', 'position', 'Kill_Proj', 'Death_Proj', 'Assist_Proj', 'CS_Proj']]
|
339 |
else:
|
340 |
team_data['Kill_Proj'] = team_data.apply(lambda row: row['lKill%'] * opp_pos_kills_boost_loss.get(row['position'], 1), axis=1) * kill_predictions[game]
|
341 |
team_data['Death_Proj'] = team_data.apply(lambda row: row['lDeath%'] * opp_pos_deaths_boost_loss.get(row['position'], 1), axis=1) * death_predictions[game]
|
342 |
+
# Calculate assists and scale them to not exceed total kills
|
343 |
+
raw_assists = team_data.apply(lambda row: row['lAssist%'] * opp_pos_assists_boost_loss.get(row['position'], 1), axis=1) * kill_predictions[game]
|
344 |
+
assist_scale = min(1.0, kill_predictions[game] / raw_assists.sum()) if raw_assists.sum() > 0 else 1.0
|
345 |
+
team_data['Assist_Proj'] = raw_assists * assist_scale
|
346 |
+
|
347 |
team_data['CS_Proj'] = team_data.apply(lambda row: row['lCS'] * opp_pos_cs_boost_loss.get(row['position'], 1), axis=1)
|
348 |
team_data = team_data[['playername', 'teamname', 'position', 'Kill_Proj', 'Death_Proj', 'Assist_Proj', 'CS_Proj']]
|
349 |
else:
|
|
|
353 |
'playername_avg_total_cs_win': 'wCS', 'playername_avg_kills_loss': 'lKill%', 'playername_avg_deaths_loss': 'lDeath%',
|
354 |
'playername_avg_assists_loss': 'lAssist%', 'playername_avg_total_cs_loss': 'lCS'})
|
355 |
team_data = working_tables.drop_duplicates(subset = ['playername'])
|
356 |
+
team_data = working_tables.drop_duplicates(subset = ['position'])
|
357 |
|
358 |
if win_loss_settings[game] == "Win":
|
359 |
team_data['Kill_Proj'] = team_data.apply(lambda row: row['wKill%'] * opp_pos_kills_boost_win.get(row['position'], 1), axis=1)
|
|
|
540 |
if win_loss_settings[game] == "Win":
|
541 |
team_data['Kill_Proj'] = team_data.apply(lambda row: row['wKill%'] * opp_pos_kills_boost_win.get(row['position'], 1), axis=1) * kill_predictions[game]
|
542 |
team_data['Death_Proj'] = team_data.apply(lambda row: row['wDeath%'] * opp_pos_deaths_boost_win.get(row['position'], 1), axis=1) * death_predictions[game]
|
543 |
+
# Calculate assists and scale them to not exceed total kills
|
544 |
+
raw_assists = team_data.apply(lambda row: row['wAssist%'] * opp_pos_assists_boost_win.get(row['position'], 1), axis=1) * kill_predictions[game]
|
545 |
+
assist_scale = min(1.0, kill_predictions[game] / raw_assists.sum()) if raw_assists.sum() > 0 else 1.0
|
546 |
+
team_data['Assist_Proj'] = raw_assists * assist_scale
|
547 |
+
|
548 |
team_data['CS_Proj'] = team_data.apply(lambda row: row['wCS'] * opp_pos_cs_boost_win.get(row['position'], 1), axis=1)
|
549 |
team_data = team_data[['playername', 'teamname', 'position', 'Kill_Proj', 'Death_Proj', 'Assist_Proj', 'CS_Proj']]
|
550 |
else:
|
551 |
team_data['Kill_Proj'] = team_data.apply(lambda row: row['lKill%'] * opp_pos_kills_boost_loss.get(row['position'], 1), axis=1) * kill_predictions[game]
|
552 |
team_data['Death_Proj'] = team_data.apply(lambda row: row['lDeath%'] * opp_pos_deaths_boost_loss.get(row['position'], 1), axis=1) * death_predictions[game]
|
553 |
+
# Calculate assists and scale them to not exceed total kills
|
554 |
+
raw_assists = team_data.apply(lambda row: row['lAssist%'] * opp_pos_assists_boost_loss.get(row['position'], 1), axis=1) * kill_predictions[game]
|
555 |
+
assist_scale = min(1.0, kill_predictions[game] / raw_assists.sum()) if raw_assists.sum() > 0 else 1.0
|
556 |
+
team_data['Assist_Proj'] = raw_assists * assist_scale
|
557 |
+
|
558 |
team_data['CS_Proj'] = team_data.apply(lambda row: row['lCS'] * opp_pos_cs_boost_loss.get(row['position'], 1), axis=1)
|
559 |
team_data = team_data[['playername', 'teamname', 'position', 'Kill_Proj', 'Death_Proj', 'Assist_Proj', 'CS_Proj']]
|
560 |
else:
|