Spaces:
Running
Running
James McCool
commited on
Commit
·
83e4ee0
1
Parent(s):
5ef09f7
Add configurable ROO parameters in sidebar for dynamic projection analysis
Browse files- app.py +19 -13
- function_hold/NBA_functions.py +8 -8
app.py
CHANGED
|
@@ -81,24 +81,30 @@ with tab1:
|
|
| 81 |
with tab2:
|
| 82 |
if st.button('Clear data', key='reset2'):
|
| 83 |
st.session_state.clear()
|
| 84 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
if projections_file:
|
| 86 |
if st.button('Build ROO'):
|
| 87 |
if sport_var == "NBA":
|
| 88 |
-
if
|
| 89 |
-
disp_file = DK_NBA_ROO_Build(projections)
|
| 90 |
-
elif
|
| 91 |
-
disp_file = FD_NBA_ROO_Build(projections)
|
| 92 |
elif sport_var == "NFL":
|
| 93 |
-
if
|
| 94 |
-
disp_file = DK_NFL_ROO_Build(projections)
|
| 95 |
-
elif
|
| 96 |
-
disp_file = FD_NFL_ROO_Build(projections)
|
| 97 |
elif sport_var == "MLB":
|
| 98 |
-
if
|
| 99 |
-
disp_file = DK_MLB_ROO_Build(projections)
|
| 100 |
-
elif
|
| 101 |
-
disp_file = FD_MLB_ROO_Build(projections)
|
| 102 |
|
| 103 |
if disp_file is not None:
|
| 104 |
st.dataframe(disp_file.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(precision=2), height=1000, use_container_width = True)
|
|
|
|
| 81 |
with tab2:
|
| 82 |
if st.button('Clear data', key='reset2'):
|
| 83 |
st.session_state.clear()
|
| 84 |
+
|
| 85 |
+
with st.sidebar:
|
| 86 |
+
site_var_sb = st.selectbox("Select Site", ["Draftkings", "Fanduel"])
|
| 87 |
+
floor_var_sb = st.number_input("Floor (low end multiplier)", min_value=0.00, max_value=.50, value=.25, step=.01)
|
| 88 |
+
ceiling_var_sb = st.number_input("Ceiling (high end multiplier)", min_value=1.50, max_value=3.00, value=2.00, step=.01)
|
| 89 |
+
std_var_sb = st.number_input("Standard Deviation (variance within distribution)", min_value=1.00, max_value=5.00, value=4.00, step=.01)
|
| 90 |
+
|
| 91 |
if projections_file:
|
| 92 |
if st.button('Build ROO'):
|
| 93 |
if sport_var == "NBA":
|
| 94 |
+
if site_var_sb == "Draftkings":
|
| 95 |
+
disp_file = DK_NBA_ROO_Build(projections, floor_var_sb, ceiling_var_sb, std_var_sb)
|
| 96 |
+
elif site_var_sb == "Fanduel":
|
| 97 |
+
disp_file = FD_NBA_ROO_Build(projections, floor_var_sb, ceiling_var_sb, std_var_sb)
|
| 98 |
elif sport_var == "NFL":
|
| 99 |
+
if site_var_sb == "Draftkings":
|
| 100 |
+
disp_file = DK_NFL_ROO_Build(projections, floor_var_sb, ceiling_var_sb, std_var_sb)
|
| 101 |
+
elif site_var_sb == "Fanduel":
|
| 102 |
+
disp_file = FD_NFL_ROO_Build(projections, floor_var_sb, ceiling_var_sb, std_var_sb)
|
| 103 |
elif sport_var == "MLB":
|
| 104 |
+
if site_var_sb == "Draftkings":
|
| 105 |
+
disp_file = DK_MLB_ROO_Build(projections, floor_var_sb, ceiling_var_sb, std_var_sb)
|
| 106 |
+
elif site_var_sb == "Fanduel":
|
| 107 |
+
disp_file = FD_MLB_ROO_Build(projections, floor_var_sb, ceiling_var_sb, std_var_sb)
|
| 108 |
|
| 109 |
if disp_file is not None:
|
| 110 |
st.dataframe(disp_file.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(precision=2), height=1000, use_container_width = True)
|
function_hold/NBA_functions.py
CHANGED
|
@@ -7,7 +7,7 @@ from pandas import concat as pd_concat
|
|
| 7 |
from pandas import merge as pd_merge
|
| 8 |
from pandas import DataFrame
|
| 9 |
|
| 10 |
-
def DK_NBA_ROO_Build(projections_file):
|
| 11 |
total_sims = 1000
|
| 12 |
|
| 13 |
projects_raw = projections_file.copy()
|
|
@@ -107,9 +107,9 @@ def DK_NBA_ROO_Build(projections_file):
|
|
| 107 |
|
| 108 |
flex_file = basic_own_df[['Player', 'Position', 'Salary', 'Median', 'Minutes']]
|
| 109 |
flex_file = flex_file.rename(columns={"Agg": "Median"})
|
| 110 |
-
flex_file['Floor'] = (flex_file['Median'] *
|
| 111 |
-
flex_file['Ceiling'] = flex_file['Median'] +
|
| 112 |
-
flex_file['STD'] = (flex_file['Median']/
|
| 113 |
flex_file = flex_file[['Player', 'Position', 'Salary', 'Floor', 'Median', 'Ceiling', 'STD']]
|
| 114 |
flex_file = flex_file.reset_index(drop=True)
|
| 115 |
hold_file = flex_file.copy()
|
|
@@ -207,7 +207,7 @@ def DK_NBA_ROO_Build(projections_file):
|
|
| 207 |
|
| 208 |
return final_Proj.copy()
|
| 209 |
|
| 210 |
-
def FD_NBA_ROO_Build(projections_file):
|
| 211 |
total_sims = 1000
|
| 212 |
|
| 213 |
projects_raw = projections_file.copy()
|
|
@@ -306,9 +306,9 @@ def FD_NBA_ROO_Build(projections_file):
|
|
| 306 |
|
| 307 |
flex_file = basic_own_df[['Player', 'Position', 'Salary', 'Median', 'Minutes']]
|
| 308 |
flex_file = flex_file.rename(columns={"Agg": "Median"})
|
| 309 |
-
flex_file['Floor'] = (flex_file['Median'] *
|
| 310 |
-
flex_file['Ceiling'] = flex_file['Median'] +
|
| 311 |
-
flex_file['STD'] = (flex_file['Median']/
|
| 312 |
flex_file = flex_file[['Player', 'Position', 'Salary', 'Floor', 'Median', 'Ceiling', 'STD']]
|
| 313 |
flex_file = flex_file.reset_index(drop=True)
|
| 314 |
hold_file = flex_file.copy()
|
|
|
|
| 7 |
from pandas import merge as pd_merge
|
| 8 |
from pandas import DataFrame
|
| 9 |
|
| 10 |
+
def DK_NBA_ROO_Build(projections_file, floor_var, ceiling_var, std_var):
|
| 11 |
total_sims = 1000
|
| 12 |
|
| 13 |
projects_raw = projections_file.copy()
|
|
|
|
| 107 |
|
| 108 |
flex_file = basic_own_df[['Player', 'Position', 'Salary', 'Median', 'Minutes']]
|
| 109 |
flex_file = flex_file.rename(columns={"Agg": "Median"})
|
| 110 |
+
flex_file['Floor'] = (flex_file['Median'] * floor_var) + (flex_file['Minutes'] * .25)
|
| 111 |
+
flex_file['Ceiling'] = flex_file['Median'] + (5 * ceiling_var) + (flex_file['Minutes'] * .25)
|
| 112 |
+
flex_file['STD'] = (flex_file['Median'] / std_var)
|
| 113 |
flex_file = flex_file[['Player', 'Position', 'Salary', 'Floor', 'Median', 'Ceiling', 'STD']]
|
| 114 |
flex_file = flex_file.reset_index(drop=True)
|
| 115 |
hold_file = flex_file.copy()
|
|
|
|
| 207 |
|
| 208 |
return final_Proj.copy()
|
| 209 |
|
| 210 |
+
def FD_NBA_ROO_Build(projections_file, floor_var, ceiling_var, std_var):
|
| 211 |
total_sims = 1000
|
| 212 |
|
| 213 |
projects_raw = projections_file.copy()
|
|
|
|
| 306 |
|
| 307 |
flex_file = basic_own_df[['Player', 'Position', 'Salary', 'Median', 'Minutes']]
|
| 308 |
flex_file = flex_file.rename(columns={"Agg": "Median"})
|
| 309 |
+
flex_file['Floor'] = (flex_file['Median'] * floor_var) + (flex_file['Minutes'] * .25)
|
| 310 |
+
flex_file['Ceiling'] = flex_file['Median'] + (5 * ceiling_var) + (flex_file['Minutes'] * .25)
|
| 311 |
+
flex_file['STD'] = (flex_file['Median'] / std_var)
|
| 312 |
flex_file = flex_file[['Player', 'Position', 'Salary', 'Floor', 'Median', 'Ceiling', 'STD']]
|
| 313 |
flex_file = flex_file.reset_index(drop=True)
|
| 314 |
hold_file = flex_file.copy()
|