James McCool
commited on
Commit
·
70c1c8d
1
Parent(s):
4411256
Refactor dupes calculation in predict_dupes function to incorporate ownership ratio adjustment based on Contest_Size, enhancing the accuracy of duplicate predictions. Additionally, modify the calculation to use a salary ratio of 50 for improved precision.
Browse files- app.py +30 -14
- global_func/predict_dupes.py +6 -8
app.py
CHANGED
|
@@ -271,20 +271,36 @@ with tab1:
|
|
| 271 |
|
| 272 |
if sport_var in stacking_sports:
|
| 273 |
team_dict = dict(zip(st.session_state['projections_df']['player_names'], st.session_state['projections_df']['team']))
|
| 274 |
-
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
|
| 278 |
-
|
| 279 |
-
|
| 280 |
-
|
| 281 |
-
|
| 282 |
-
|
| 283 |
-
|
| 284 |
-
|
| 285 |
-
|
| 286 |
-
|
| 287 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 288 |
st.session_state['stack_dict'] = dict(zip(st.session_state['portfolio'].index, st.session_state['portfolio']['Stack']))
|
| 289 |
st.session_state['size_dict'] = dict(zip(st.session_state['portfolio'].index, st.session_state['portfolio']['Size']))
|
| 290 |
|
|
|
|
| 271 |
|
| 272 |
if sport_var in stacking_sports:
|
| 273 |
team_dict = dict(zip(st.session_state['projections_df']['player_names'], st.session_state['projections_df']['team']))
|
| 274 |
+
if sport_var == 'LOL':
|
| 275 |
+
st.session_state['portfolio']['Stack'] = st.session_state['portfolio'].apply(
|
| 276 |
+
lambda row: Counter(
|
| 277 |
+
team_dict.get(player, '') for player in row
|
| 278 |
+
if team_dict.get(player, '') != ''
|
| 279 |
+
).most_common(1)[0][0] if any(team_dict.get(player, '') for player in row) else '',
|
| 280 |
+
axis=1
|
| 281 |
+
)
|
| 282 |
+
st.session_state['portfolio']['Size'] = st.session_state['portfolio'].apply(
|
| 283 |
+
lambda row: Counter(
|
| 284 |
+
team_dict.get(player, '') for player in row
|
| 285 |
+
if team_dict.get(player, '') != ''
|
| 286 |
+
).most_common(1)[0][1] if any(team_dict.get(player, '') for player in row) else 0,
|
| 287 |
+
axis=1
|
| 288 |
+
)
|
| 289 |
+
else:
|
| 290 |
+
st.session_state['portfolio']['Stack'] = st.session_state['portfolio'].apply(
|
| 291 |
+
lambda row: Counter(
|
| 292 |
+
team_dict.get(player, '') for player in row[2:]
|
| 293 |
+
if team_dict.get(player, '') != ''
|
| 294 |
+
).most_common(1)[0][0] if any(team_dict.get(player, '') for player in row[2:]) else '',
|
| 295 |
+
axis=1
|
| 296 |
+
)
|
| 297 |
+
st.session_state['portfolio']['Size'] = st.session_state['portfolio'].apply(
|
| 298 |
+
lambda row: Counter(
|
| 299 |
+
team_dict.get(player, '') for player in row[2:]
|
| 300 |
+
if team_dict.get(player, '') != ''
|
| 301 |
+
).most_common(1)[0][1] if any(team_dict.get(player, '') for player in row[2:]) else 0,
|
| 302 |
+
axis=1
|
| 303 |
+
)
|
| 304 |
st.session_state['stack_dict'] = dict(zip(st.session_state['portfolio'].index, st.session_state['portfolio']['Stack']))
|
| 305 |
st.session_state['size_dict'] = dict(zip(st.session_state['portfolio'].index, st.session_state['portfolio']['Size']))
|
| 306 |
|
global_func/predict_dupes.py
CHANGED
|
@@ -329,7 +329,7 @@ def predict_dupes(portfolio, maps_dict, site_var, type_var, Contest_Size, streng
|
|
| 329 |
|
| 330 |
# Calculate dupes formula
|
| 331 |
portfolio['dupes_calc'] = (portfolio['own_product'] * portfolio['avg_own_rank']) * (portfolio['Own'] / 100) * Contest_Size + ((portfolio['salary'] - (60000 - portfolio['Own'])) / 100) - ((60000 - portfolio['salary']) / 100)
|
| 332 |
-
portfolio['dupes_calc'] = portfolio['dupes_calc'] * dupes_multiplier
|
| 333 |
|
| 334 |
# Round and handle negative values
|
| 335 |
portfolio['Dupes'] = np.where(
|
|
@@ -355,7 +355,7 @@ def predict_dupes(portfolio, maps_dict, site_var, type_var, Contest_Size, streng
|
|
| 355 |
portfolio['avg_own_rank'] = portfolio[dup_count_columns].mean(axis=1)
|
| 356 |
|
| 357 |
portfolio['dupes_calc'] = (portfolio['own_product'] * portfolio['avg_own_rank']) * Contest_Size + ((portfolio['salary'] - (60000 - portfolio['Own'])) / 100) - ((60000 - portfolio['salary']) / 100)
|
| 358 |
-
portfolio['dupes_calc'] = portfolio['dupes_calc'] * dupes_multiplier
|
| 359 |
# Round and handle negative values
|
| 360 |
portfolio['Dupes'] = np.where(
|
| 361 |
np.round(portfolio['dupes_calc'], 0) <= 0,
|
|
@@ -430,7 +430,7 @@ def predict_dupes(portfolio, maps_dict, site_var, type_var, Contest_Size, streng
|
|
| 430 |
|
| 431 |
# Calculate dupes formula
|
| 432 |
portfolio['dupes_calc'] = (portfolio['own_product'] * portfolio['avg_own_rank']) * Contest_Size + ((portfolio['salary'] - (50000 - portfolio['Own'])) / 100) - ((50000 - portfolio['salary']) / 100)
|
| 433 |
-
portfolio['dupes_calc'] = portfolio['dupes_calc'] * dupes_multiplier
|
| 434 |
|
| 435 |
# Round and handle negative values
|
| 436 |
portfolio['Dupes'] = np.where(
|
|
@@ -476,8 +476,8 @@ def predict_dupes(portfolio, maps_dict, site_var, type_var, Contest_Size, streng
|
|
| 476 |
portfolio['avg_own_rank'] = portfolio[dup_count_columns].mean(axis=1)
|
| 477 |
|
| 478 |
# Calculate dupes formula
|
| 479 |
-
portfolio['dupes_calc'] = (portfolio['own_product'] * portfolio['avg_own_rank']) * Contest_Size + ((portfolio['salary'] - (50000 - portfolio['Own'])) /
|
| 480 |
-
portfolio['dupes_calc'] = portfolio['dupes_calc'] * dupes_multiplier
|
| 481 |
|
| 482 |
# Round and handle negative values
|
| 483 |
portfolio['Dupes'] = np.where(
|
|
@@ -523,8 +523,6 @@ def predict_dupes(portfolio, maps_dict, site_var, type_var, Contest_Size, streng
|
|
| 523 |
portfolio['own_average'] = (portfolio['Own'].max() * .33) / 100
|
| 524 |
portfolio['own_sum'] = portfolio[own_columns].sum(axis=1)
|
| 525 |
portfolio['avg_own_rank'] = portfolio[dup_count_columns].mean(axis=1)
|
| 526 |
-
|
| 527 |
-
print(portfolio[['Own', 'own_product', 'own_average', 'own_sum', 'avg_own_rank']].head(10))
|
| 528 |
|
| 529 |
# Calculate dupes formula
|
| 530 |
portfolio['dupes_calc'] = ((portfolio['own_product'] * 10) * portfolio['avg_own_rank']) * Contest_Size + ((portfolio['salary'] - (50000 - portfolio['Own'])) / 50) - ((50000 - portfolio['salary']) / 50)
|
|
@@ -554,7 +552,7 @@ def predict_dupes(portfolio, maps_dict, site_var, type_var, Contest_Size, streng
|
|
| 554 |
portfolio['avg_own_rank'] = portfolio[dup_count_columns].mean(axis=1)
|
| 555 |
|
| 556 |
portfolio['dupes_calc'] = (portfolio['own_product'] * portfolio['avg_own_rank']) * Contest_Size + ((portfolio['salary'] - (50000 - portfolio['Own'])) / 100) - ((50000 - portfolio['salary']) / 100)
|
| 557 |
-
portfolio['dupes_calc'] = portfolio['dupes_calc'] * dupes_multiplier
|
| 558 |
# Round and handle negative values
|
| 559 |
portfolio['Dupes'] = np.where(
|
| 560 |
np.round(portfolio['dupes_calc'], 0) <= 0,
|
|
|
|
| 329 |
|
| 330 |
# Calculate dupes formula
|
| 331 |
portfolio['dupes_calc'] = (portfolio['own_product'] * portfolio['avg_own_rank']) * (portfolio['Own'] / 100) * Contest_Size + ((portfolio['salary'] - (60000 - portfolio['Own'])) / 100) - ((60000 - portfolio['salary']) / 100)
|
| 332 |
+
portfolio['dupes_calc'] = portfolio['dupes_calc'] * dupes_multiplier * (portfolio['Own'] / (100 + (Contest_Size / 1000)))
|
| 333 |
|
| 334 |
# Round and handle negative values
|
| 335 |
portfolio['Dupes'] = np.where(
|
|
|
|
| 355 |
portfolio['avg_own_rank'] = portfolio[dup_count_columns].mean(axis=1)
|
| 356 |
|
| 357 |
portfolio['dupes_calc'] = (portfolio['own_product'] * portfolio['avg_own_rank']) * Contest_Size + ((portfolio['salary'] - (60000 - portfolio['Own'])) / 100) - ((60000 - portfolio['salary']) / 100)
|
| 358 |
+
portfolio['dupes_calc'] = portfolio['dupes_calc'] * dupes_multiplier * (portfolio['Own'] / (100 + (Contest_Size / 1000)))
|
| 359 |
# Round and handle negative values
|
| 360 |
portfolio['Dupes'] = np.where(
|
| 361 |
np.round(portfolio['dupes_calc'], 0) <= 0,
|
|
|
|
| 430 |
|
| 431 |
# Calculate dupes formula
|
| 432 |
portfolio['dupes_calc'] = (portfolio['own_product'] * portfolio['avg_own_rank']) * Contest_Size + ((portfolio['salary'] - (50000 - portfolio['Own'])) / 100) - ((50000 - portfolio['salary']) / 100)
|
| 433 |
+
portfolio['dupes_calc'] = portfolio['dupes_calc'] * dupes_multiplier * (portfolio['Own'] / (100 + (Contest_Size / 1000)))
|
| 434 |
|
| 435 |
# Round and handle negative values
|
| 436 |
portfolio['Dupes'] = np.where(
|
|
|
|
| 476 |
portfolio['avg_own_rank'] = portfolio[dup_count_columns].mean(axis=1)
|
| 477 |
|
| 478 |
# Calculate dupes formula
|
| 479 |
+
portfolio['dupes_calc'] = ((portfolio['own_product'] * 10) * portfolio['avg_own_rank']) * Contest_Size + ((portfolio['salary'] - (50000 - portfolio['Own'])) / 50) - ((50000 - portfolio['salary']) / 50)
|
| 480 |
+
portfolio['dupes_calc'] = portfolio['dupes_calc'] * dupes_multiplier * (portfolio['Own'] / (100 + (Contest_Size / 1000)))
|
| 481 |
|
| 482 |
# Round and handle negative values
|
| 483 |
portfolio['Dupes'] = np.where(
|
|
|
|
| 523 |
portfolio['own_average'] = (portfolio['Own'].max() * .33) / 100
|
| 524 |
portfolio['own_sum'] = portfolio[own_columns].sum(axis=1)
|
| 525 |
portfolio['avg_own_rank'] = portfolio[dup_count_columns].mean(axis=1)
|
|
|
|
|
|
|
| 526 |
|
| 527 |
# Calculate dupes formula
|
| 528 |
portfolio['dupes_calc'] = ((portfolio['own_product'] * 10) * portfolio['avg_own_rank']) * Contest_Size + ((portfolio['salary'] - (50000 - portfolio['Own'])) / 50) - ((50000 - portfolio['salary']) / 50)
|
|
|
|
| 552 |
portfolio['avg_own_rank'] = portfolio[dup_count_columns].mean(axis=1)
|
| 553 |
|
| 554 |
portfolio['dupes_calc'] = (portfolio['own_product'] * portfolio['avg_own_rank']) * Contest_Size + ((portfolio['salary'] - (50000 - portfolio['Own'])) / 100) - ((50000 - portfolio['salary']) / 100)
|
| 555 |
+
portfolio['dupes_calc'] = portfolio['dupes_calc'] * dupes_multiplier * (portfolio['Own'] / (100 + (Contest_Size / 1000)))
|
| 556 |
# Round and handle negative values
|
| 557 |
portfolio['Dupes'] = np.where(
|
| 558 |
np.round(portfolio['dupes_calc'], 0) <= 0,
|