Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -10,6 +10,7 @@ import pandas as pd
|
|
| 10 |
import streamlit as st
|
| 11 |
import gspread
|
| 12 |
import random
|
|
|
|
| 13 |
|
| 14 |
@st.cache_resource
|
| 15 |
def init_conn():
|
|
@@ -146,14 +147,14 @@ def run_seed_frame(seed_depth1, Strength_var, strength_grow, Teams_used, Total_R
|
|
| 146 |
while RunsVar <= seed_depth_def:
|
| 147 |
if RunsVar <= 3:
|
| 148 |
FieldStrength = Strength_var_def
|
| 149 |
-
FinalPortfolio, maps_dict = get_correlated_portfolio_for_sim(Total_Runs_def * .
|
| 150 |
-
FinalPortfolio2, maps_dict2 = get_uncorrelated_portfolio_for_sim(Total_Runs_def * .
|
| 151 |
FinalPortfolio_init = pd.concat([FinalPortfolio, FinalPortfolio2], axis=0)
|
| 152 |
maps_dict.update(maps_dict2)
|
| 153 |
elif RunsVar > 3 and RunsVar <= 4:
|
| 154 |
FieldStrength += (strength_grow_def + ((30 - len(Teams_used_def)) * .001))
|
| 155 |
-
FinalPortfolio3, maps_dict3 = get_correlated_portfolio_for_sim(Total_Runs_def * .
|
| 156 |
-
FinalPortfolio4, maps_dict4 = get_uncorrelated_portfolio_for_sim(Total_Runs_def * .
|
| 157 |
FinalPortfolio_merge_3 = pd.concat([FinalPortfolio_init, FinalPortfolio3], axis=0)
|
| 158 |
FinalPortfolio_merge_4 = pd.concat([FinalPortfolio_merge_3, FinalPortfolio4], axis=0)
|
| 159 |
FinalPortfolio_step_2 = FinalPortfolio_merge_4.drop_duplicates(subset = ['Projection', 'Own'],keep = 'last').reset_index(drop = True)
|
|
@@ -161,8 +162,8 @@ def run_seed_frame(seed_depth1, Strength_var, strength_grow, Teams_used, Total_R
|
|
| 161 |
maps_dict.update(maps_dict4)
|
| 162 |
elif RunsVar > 4:
|
| 163 |
FieldStrength = 1
|
| 164 |
-
FinalPortfolio5, maps_dict5 = get_correlated_portfolio_for_sim(Total_Runs_def * .
|
| 165 |
-
FinalPortfolio6, maps_dict6 = get_uncorrelated_portfolio_for_sim(Total_Runs_def * .
|
| 166 |
FinalPortfolio_merge_5 = pd.concat([FinalPortfolio_step_2, FinalPortfolio5], axis=0)
|
| 167 |
FinalPortfolio_merge_6 = pd.concat([FinalPortfolio_merge_5, FinalPortfolio6], axis=0)
|
| 168 |
FinalPortfolio_export = FinalPortfolio_merge_6.drop_duplicates(subset = ['Projection', 'Own'],keep = 'last').reset_index(drop = True)
|
|
@@ -956,7 +957,7 @@ with tab2:
|
|
| 956 |
'team_check_map':dict(zip(cleaport_players.Player,nerf_frame.Team))
|
| 957 |
}
|
| 958 |
|
| 959 |
-
FinalPortfolio, maps_dict = run_seed_frame(
|
| 960 |
|
| 961 |
Sim_Winners = sim_contest(2500, FinalPortfolio, CleanPortfolio, maps_dict, up_dict, insert_port)
|
| 962 |
|
|
@@ -1168,4 +1169,6 @@ del dkid_dict, fdid_dict
|
|
| 1168 |
del static_exposure, overall_exposure
|
| 1169 |
del insert_port1, Contest_Size, sharp_split, Strength_var, scaling_var, Sort_function, Sim_function, strength_grow, field_growth
|
| 1170 |
del raw_baselines
|
| 1171 |
-
del freq_format
|
|
|
|
|
|
|
|
|
| 10 |
import streamlit as st
|
| 11 |
import gspread
|
| 12 |
import random
|
| 13 |
+
import gc
|
| 14 |
|
| 15 |
@st.cache_resource
|
| 16 |
def init_conn():
|
|
|
|
| 147 |
while RunsVar <= seed_depth_def:
|
| 148 |
if RunsVar <= 3:
|
| 149 |
FieldStrength = Strength_var_def
|
| 150 |
+
FinalPortfolio, maps_dict = get_correlated_portfolio_for_sim(Total_Runs_def * .1, sharp_split, field_growth)
|
| 151 |
+
FinalPortfolio2, maps_dict2 = get_uncorrelated_portfolio_for_sim(Total_Runs_def * .1, sharp_split, field_growth)
|
| 152 |
FinalPortfolio_init = pd.concat([FinalPortfolio, FinalPortfolio2], axis=0)
|
| 153 |
maps_dict.update(maps_dict2)
|
| 154 |
elif RunsVar > 3 and RunsVar <= 4:
|
| 155 |
FieldStrength += (strength_grow_def + ((30 - len(Teams_used_def)) * .001))
|
| 156 |
+
FinalPortfolio3, maps_dict3 = get_correlated_portfolio_for_sim(Total_Runs_def * .1, sharp_split, field_growth)
|
| 157 |
+
FinalPortfolio4, maps_dict4 = get_uncorrelated_portfolio_for_sim(Total_Runs_def * .1, sharp_split, field_growth)
|
| 158 |
FinalPortfolio_merge_3 = pd.concat([FinalPortfolio_init, FinalPortfolio3], axis=0)
|
| 159 |
FinalPortfolio_merge_4 = pd.concat([FinalPortfolio_merge_3, FinalPortfolio4], axis=0)
|
| 160 |
FinalPortfolio_step_2 = FinalPortfolio_merge_4.drop_duplicates(subset = ['Projection', 'Own'],keep = 'last').reset_index(drop = True)
|
|
|
|
| 162 |
maps_dict.update(maps_dict4)
|
| 163 |
elif RunsVar > 4:
|
| 164 |
FieldStrength = 1
|
| 165 |
+
FinalPortfolio5, maps_dict5 = get_correlated_portfolio_for_sim(Total_Runs_def * .1, sharp_split, field_growth)
|
| 166 |
+
FinalPortfolio6, maps_dict6 = get_uncorrelated_portfolio_for_sim(Total_Runs_def * .1, sharp_split, field_growth)
|
| 167 |
FinalPortfolio_merge_5 = pd.concat([FinalPortfolio_step_2, FinalPortfolio5], axis=0)
|
| 168 |
FinalPortfolio_merge_6 = pd.concat([FinalPortfolio_merge_5, FinalPortfolio6], axis=0)
|
| 169 |
FinalPortfolio_export = FinalPortfolio_merge_6.drop_duplicates(subset = ['Projection', 'Own'],keep = 'last').reset_index(drop = True)
|
|
|
|
| 957 |
'team_check_map':dict(zip(cleaport_players.Player,nerf_frame.Team))
|
| 958 |
}
|
| 959 |
|
| 960 |
+
FinalPortfolio, maps_dict = run_seed_frame(5, Strength_var, strength_grow, Teams_used, 1000000, field_growth)
|
| 961 |
|
| 962 |
Sim_Winners = sim_contest(2500, FinalPortfolio, CleanPortfolio, maps_dict, up_dict, insert_port)
|
| 963 |
|
|
|
|
| 1169 |
del static_exposure, overall_exposure
|
| 1170 |
del insert_port1, Contest_Size, sharp_split, Strength_var, scaling_var, Sort_function, Sim_function, strength_grow, field_growth
|
| 1171 |
del raw_baselines
|
| 1172 |
+
del freq_format
|
| 1173 |
+
|
| 1174 |
+
gc.collect()
|