Spaces:
Running
Running
James McCool
commited on
Commit
·
7e17f0f
1
Parent(s):
9e23c76
Enhance player summary generation in init_team_data function of app.py. Introduced a results dictionary to aggregate player statistics across multiple games, allowing for a comprehensive summary of performance metrics. Updated the return statement to include the new player summary DataFrame, improving the clarity and usability of simulation results for users.
Browse files
app.py
CHANGED
@@ -299,6 +299,8 @@ def init_team_data(team, opponent, win_loss_settings, kill_predictions, death_pr
|
|
299 |
'opp_pos_cs_boost_loss': opp_pos_cs_boost_loss
|
300 |
}).set_index(pd.Index(list(opp_pos_kills_boost_win.keys()), name='position'))
|
301 |
|
|
|
|
|
302 |
for game in range(game_count):
|
303 |
if kill_predictions[game] > 0:
|
304 |
working_tables = player_tables[['playername', 'teamname', 'position', 'playername_avg_kill_share_win', 'playername_avg_death_share_win','playername_avg_assist_share_win',
|
@@ -340,14 +342,26 @@ def init_team_data(team, opponent, win_loss_settings, kill_predictions, death_pr
|
|
340 |
team_data['Assist_Proj'] = team_data.apply(lambda row: row['lAssist%'] * opp_pos_assists_boost_loss.get(row['position'], 1), axis=1)
|
341 |
team_data['CS_Proj'] = team_data.apply(lambda row: row['lCS'] * opp_pos_cs_boost_loss.get(row['position'], 1), axis=1)
|
342 |
team_data = team_data[['playername', 'teamname', 'position', 'Kill_Proj', 'Death_Proj', 'Assist_Proj', 'CS_Proj']]
|
|
|
|
|
343 |
team_data['playername'] = team_data['playername'] + f' game {game + 1}'
|
344 |
|
345 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
346 |
|
347 |
-
return overall_team_data.dropna().set_index('playername'), opp_boosts
|
348 |
|
349 |
if st.button("Run"):
|
350 |
-
team_data, opp_boost = init_team_data(selected_team, selected_opponent, win_loss_settings, kill_predictions, death_predictions, start_date, end_date)
|
351 |
|
352 |
# Create simulated percentiles
|
353 |
sim_results = []
|
@@ -380,6 +394,7 @@ if st.button("Run"):
|
|
380 |
|
381 |
tab1, tab2 = st.tabs(["Team Data", "Opponent Data"])
|
382 |
with tab1:
|
|
|
383 |
st.dataframe(team_data.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(display_formats, precision=2), use_container_width = True)
|
384 |
with tab2:
|
385 |
st.dataframe(opp_boost.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(precision=2), use_container_width = True)
|
@@ -390,8 +405,9 @@ if st.button("Run"):
|
|
390 |
for player, tab in zip(unique_players, player_tabs):
|
391 |
with tab:
|
392 |
player_data = sim_df[sim_df['Player'] == player]
|
|
|
393 |
st.dataframe(
|
394 |
-
player_data[['
|
395 |
.style.format(precision=2),
|
396 |
use_container_width=True
|
397 |
)
|
|
|
299 |
'opp_pos_cs_boost_loss': opp_pos_cs_boost_loss
|
300 |
}).set_index(pd.Index(list(opp_pos_kills_boost_win.keys()), name='position'))
|
301 |
|
302 |
+
results_dict = {}
|
303 |
+
|
304 |
for game in range(game_count):
|
305 |
if kill_predictions[game] > 0:
|
306 |
working_tables = player_tables[['playername', 'teamname', 'position', 'playername_avg_kill_share_win', 'playername_avg_death_share_win','playername_avg_assist_share_win',
|
|
|
342 |
team_data['Assist_Proj'] = team_data.apply(lambda row: row['lAssist%'] * opp_pos_assists_boost_loss.get(row['position'], 1), axis=1)
|
343 |
team_data['CS_Proj'] = team_data.apply(lambda row: row['lCS'] * opp_pos_cs_boost_loss.get(row['position'], 1), axis=1)
|
344 |
team_data = team_data[['playername', 'teamname', 'position', 'Kill_Proj', 'Death_Proj', 'Assist_Proj', 'CS_Proj']]
|
345 |
+
|
346 |
+
results_dict[f'game {game + 1}'] = team_data
|
347 |
team_data['playername'] = team_data['playername'] + f' game {game + 1}'
|
348 |
|
349 |
+
player_summary = pd.DataFrame()
|
350 |
+
for game_count, game_df in results_dict.items():
|
351 |
+
if player_summary.empty:
|
352 |
+
player_summary = game_df
|
353 |
+
else:
|
354 |
+
player_summary.update(game_df)
|
355 |
+
for col in ['Kill_Proj', 'Death_Proj', 'Assist_Proj', 'CS_Proj']:
|
356 |
+
player_summary[col] += game_df[col]
|
357 |
+
player_summary = player_summary.set_index('playername')
|
358 |
+
|
359 |
+
overall_team_data = pd.concat([overall_team_data, team_data])
|
360 |
|
361 |
+
return overall_team_data.dropna().set_index('playername'), opp_boosts, player_summary
|
362 |
|
363 |
if st.button("Run"):
|
364 |
+
team_data, opp_boost, player_summary = init_team_data(selected_team, selected_opponent, win_loss_settings, kill_predictions, death_predictions, start_date, end_date)
|
365 |
|
366 |
# Create simulated percentiles
|
367 |
sim_results = []
|
|
|
394 |
|
395 |
tab1, tab2 = st.tabs(["Team Data", "Opponent Data"])
|
396 |
with tab1:
|
397 |
+
st.dataframe(player_summary.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(display_formats, precision=2), use_container_width = True)
|
398 |
st.dataframe(team_data.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(display_formats, precision=2), use_container_width = True)
|
399 |
with tab2:
|
400 |
st.dataframe(opp_boost.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(precision=2), use_container_width = True)
|
|
|
405 |
for player, tab in zip(unique_players, player_tabs):
|
406 |
with tab:
|
407 |
player_data = sim_df[sim_df['Player'] == player]
|
408 |
+
player_data = player_data.set_index('Stat')
|
409 |
st.dataframe(
|
410 |
+
player_data[['10%', '25%', '50%', '75%', '90%']]
|
411 |
.style.format(precision=2),
|
412 |
use_container_width=True
|
413 |
)
|