Spaces:
Running
Running
James McCool
commited on
Commit
·
f268eb0
1
Parent(s):
55ed614
Refactor statistical calculations in init_team_data function of app.py. Replaced direct calculations for kill, death, assist, and CS projections with apply method for improved readability and performance. This change enhances the clarity of the code and maintains the accuracy of team performance evaluations based on opponent statistics.
Browse files
app.py
CHANGED
@@ -288,16 +288,16 @@ def init_team_data(team, opponent, win_loss, kill_prediction, death_prediction,
|
|
288 |
team_data = player_tables.drop_duplicates(subset = ['playername'])
|
289 |
|
290 |
if win_loss == "Win":
|
291 |
-
team_data['Kill_Proj'] = (
|
292 |
-
team_data['Death_Proj'] = (
|
293 |
-
team_data['Assist_Proj'] = (
|
294 |
-
team_data['CS_Proj'] = (
|
295 |
team_data = team_data[['playername', 'teamname', 'position', 'Kill_Proj', 'Death_Proj', 'Assist_Proj', 'CS_Proj']]
|
296 |
else:
|
297 |
-
team_data['Kill_Proj'] = (
|
298 |
-
team_data['Death_Proj'] = (
|
299 |
-
team_data['Assist_Proj'] = (
|
300 |
-
team_data['CS_Proj'] = (
|
301 |
team_data = team_data[['playername', 'teamname', 'position', 'Kill_Proj', 'Death_Proj', 'Assist_Proj', 'CS_Proj']]
|
302 |
else:
|
303 |
player_tables = player_tables[['playername', 'teamname', 'position', 'playername_avg_kills_win', 'playername_avg_deaths_win', 'playername_avg_assists_win', 'playername_avg_total_cs_win',
|
@@ -308,16 +308,16 @@ def init_team_data(team, opponent, win_loss, kill_prediction, death_prediction,
|
|
308 |
team_data = player_tables.drop_duplicates(subset = ['playername'])
|
309 |
|
310 |
if win_loss == "Win":
|
311 |
-
team_data['Kill_Proj'] = (
|
312 |
-
team_data['Death_Proj'] = (
|
313 |
-
team_data['Assist_Proj'] = (
|
314 |
-
team_data['CS_Proj'] = (
|
315 |
team_data = team_data[['playername', 'teamname', 'position', 'Kill_Proj', 'Death_Proj', 'Assist_Proj', 'CS_Proj']]
|
316 |
else:
|
317 |
-
team_data['Kill_Proj'] = (
|
318 |
-
team_data['Death_Proj'] = (
|
319 |
-
team_data['Assist_Proj'] = (
|
320 |
-
team_data['CS_Proj'] = (
|
321 |
team_data = team_data[['playername', 'teamname', 'position', 'Kill_Proj', 'Death_Proj', 'Assist_Proj', 'CS_Proj']]
|
322 |
|
323 |
return team_data.dropna().reset_index(drop=True)
|
|
|
288 |
team_data = player_tables.drop_duplicates(subset = ['playername'])
|
289 |
|
290 |
if win_loss == "Win":
|
291 |
+
team_data['Kill_Proj'] = team_data.apply(lambda row: row['wKill%'] * opp_pos_kills_boost_win.get(row['position'], 1), axis=1)
|
292 |
+
team_data['Death_Proj'] = team_data.apply(lambda row: row['wDeath%'] * opp_pos_deaths_boost_win.get(row['position'], 1), axis=1)
|
293 |
+
team_data['Assist_Proj'] = team_data.apply(lambda row: row['wAssist%'] * opp_pos_assists_boost_win.get(row['position'], 1), axis=1)
|
294 |
+
team_data['CS_Proj'] = team_data.apply(lambda row: row['wCS'] * opp_pos_cs_boost_win.get(row['position'], 1), axis=1)
|
295 |
team_data = team_data[['playername', 'teamname', 'position', 'Kill_Proj', 'Death_Proj', 'Assist_Proj', 'CS_Proj']]
|
296 |
else:
|
297 |
+
team_data['Kill_Proj'] = team_data.apply(lambda row: row['lKill%'] * opp_pos_kills_boost_loss.get(row['position'], 1), axis=1)
|
298 |
+
team_data['Death_Proj'] = team_data.apply(lambda row: row['lDeath%'] * opp_pos_deaths_boost_loss.get(row['position'], 1), axis=1)
|
299 |
+
team_data['Assist_Proj'] = team_data.apply(lambda row: row['lAssist%'] * opp_pos_assists_boost_loss.get(row['position'], 1), axis=1)
|
300 |
+
team_data['CS_Proj'] = team_data.apply(lambda row: row['lCS'] * opp_pos_cs_boost_loss.get(row['position'], 1), axis=1)
|
301 |
team_data = team_data[['playername', 'teamname', 'position', 'Kill_Proj', 'Death_Proj', 'Assist_Proj', 'CS_Proj']]
|
302 |
else:
|
303 |
player_tables = player_tables[['playername', 'teamname', 'position', 'playername_avg_kills_win', 'playername_avg_deaths_win', 'playername_avg_assists_win', 'playername_avg_total_cs_win',
|
|
|
308 |
team_data = player_tables.drop_duplicates(subset = ['playername'])
|
309 |
|
310 |
if win_loss == "Win":
|
311 |
+
team_data['Kill_Proj'] = team_data.apply(lambda row: row['wKill%'] * opp_pos_kills_boost_win.get(row['position'], 1), axis=1)
|
312 |
+
team_data['Death_Proj'] = team_data.apply(lambda row: row['wDeath%'] * opp_pos_deaths_boost_win.get(row['position'], 1), axis=1)
|
313 |
+
team_data['Assist_Proj'] = team_data.apply(lambda row: row['wAssist%'] * opp_pos_assists_boost_win.get(row['position'], 1), axis=1)
|
314 |
+
team_data['CS_Proj'] = team_data.apply(lambda row: row['wCS'] * opp_pos_cs_boost_win.get(row['position'], 1), axis=1)
|
315 |
team_data = team_data[['playername', 'teamname', 'position', 'Kill_Proj', 'Death_Proj', 'Assist_Proj', 'CS_Proj']]
|
316 |
else:
|
317 |
+
team_data['Kill_Proj'] = team_data.apply(lambda row: row['lKill%'] * opp_pos_kills_boost_loss.get(row['position'], 1), axis=1)
|
318 |
+
team_data['Death_Proj'] = team_data.apply(lambda row: row['lDeath%'] * opp_pos_deaths_boost_loss.get(row['position'], 1), axis=1)
|
319 |
+
team_data['Assist_Proj'] = team_data.apply(lambda row: row['lAssist%'] * opp_pos_assists_boost_loss.get(row['position'], 1), axis=1)
|
320 |
+
team_data['CS_Proj'] = team_data.apply(lambda row: row['lCS'] * opp_pos_cs_boost_loss.get(row['position'], 1), axis=1)
|
321 |
team_data = team_data[['playername', 'teamname', 'position', 'Kill_Proj', 'Death_Proj', 'Assist_Proj', 'CS_Proj']]
|
322 |
|
323 |
return team_data.dropna().reset_index(drop=True)
|