Spaces:
Running
Running
James McCool
commited on
Commit
·
d6b4eb2
1
Parent(s):
b2664c1
Enhance team data processing in init_player_data function by adding retrieval of team statistics. Introduced a new query to fetch team data based on unique team names, improving the accuracy of team performance metrics. Updated the logic to conditionally apply team statistics calculations, ensuring proper integration with player data. This change enhances the overall integrity of performance metrics during simulations.
Browse files
app.py
CHANGED
@@ -391,10 +391,15 @@ def init_player_data(game_count, players, opponent, win_loss_settings, kill_pred
|
|
391 |
cursor = collection.find({"playername": {"$in": players}, "date": {"$gte": start_datetime, "$lte": end_datetime}})
|
392 |
raw_display = pd.DataFrame(list(cursor))
|
393 |
|
|
|
|
|
|
|
|
|
|
|
394 |
cursor = collection.find({"date": {"$gte": start_datetime, "$lte": end_datetime}})
|
395 |
raw_opponent = pd.DataFrame(list(cursor))
|
396 |
|
397 |
-
tables_to_loop = [raw_display, raw_opponent]
|
398 |
|
399 |
for loop in range(len(tables_to_loop)):
|
400 |
tables = tables_to_loop[loop]
|
@@ -430,17 +435,18 @@ def init_player_data(game_count, players, opponent, win_loss_settings, kill_pred
|
|
430 |
axis=1
|
431 |
)
|
432 |
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
|
|
444 |
|
445 |
tables['playername_avg_kill_share_win'] = tables['playername_avg_kills_win'] / tables['teamname_avg_kills_win']
|
446 |
tables['playername_avg_death_share_win'] = tables['playername_avg_deaths_win'] / tables['teamname_avg_deaths_win']
|
|
|
391 |
cursor = collection.find({"playername": {"$in": players}, "date": {"$gte": start_datetime, "$lte": end_datetime}})
|
392 |
raw_display = pd.DataFrame(list(cursor))
|
393 |
|
394 |
+
teams = raw_display['teamname'].unique()
|
395 |
+
|
396 |
+
cursor = collection.find({"teamname": {"$in": teams}, "date": {"$gte": start_datetime, "$lte": end_datetime}})
|
397 |
+
raw_team = pd.DataFrame(list(cursor))
|
398 |
+
|
399 |
cursor = collection.find({"date": {"$gte": start_datetime, "$lte": end_datetime}})
|
400 |
raw_opponent = pd.DataFrame(list(cursor))
|
401 |
|
402 |
+
tables_to_loop = [raw_display, raw_opponent, raw_team]
|
403 |
|
404 |
for loop in range(len(tables_to_loop)):
|
405 |
tables = tables_to_loop[loop]
|
|
|
435 |
axis=1
|
436 |
)
|
437 |
|
438 |
+
if loop == 2:
|
439 |
+
column_name = f'teamname_avg_{stat}_win'
|
440 |
+
tables[column_name] = tables.apply(
|
441 |
+
lambda row: teamname_win_stats[stat].get(row['teamname'], 0),
|
442 |
+
axis=1
|
443 |
+
)
|
444 |
+
|
445 |
+
column_name = f'teamname_avg_{stat}_loss'
|
446 |
+
tables[column_name] = tables.apply(
|
447 |
+
lambda row: teamname_loss_stats[stat].get(row['teamname'], 0),
|
448 |
+
axis=1
|
449 |
+
)
|
450 |
|
451 |
tables['playername_avg_kill_share_win'] = tables['playername_avg_kills_win'] / tables['teamname_avg_kills_win']
|
452 |
tables['playername_avg_death_share_win'] = tables['playername_avg_deaths_win'] / tables['teamname_avg_deaths_win']
|