Spaces:
Running
Running
James McCool
commited on
Commit
·
1cb9fed
1
Parent(s):
9356756
Enhance MMA ROO functions with combined knockout and submission odds probability calculation
Browse files- app.py +2 -2
- function_hold/MMA_functions.py +17 -6
app.py
CHANGED
|
@@ -52,7 +52,7 @@ with tab1:
|
|
| 52 |
elif sport_var == "MLB":
|
| 53 |
st.info("upload a projections file that has Data oriented in the following format: 'Player', 'Team', 'Opp', 'Position', 'Salary', 'Median', 'Minutes', 'Own'")
|
| 54 |
elif sport_var == "MMA":
|
| 55 |
-
st.info("upload a projections file that has Data oriented in the following format: 'Player', 'Salary', 'Median', 'KO
|
| 56 |
# Create two columns for the uploader and template button
|
| 57 |
upload_col, template_col = st.columns([3, 1])
|
| 58 |
|
|
@@ -67,7 +67,7 @@ with tab1:
|
|
| 67 |
elif sport_var == "MLB":
|
| 68 |
template_df = pd.DataFrame(columns=['Player', 'Team', 'Opp', 'Position', 'Salary', 'Median', 'Minutes', 'Own'])
|
| 69 |
elif sport_var == "MMA":
|
| 70 |
-
template_df = pd.DataFrame(columns=['Player', 'Salary', 'Median', 'KO_var', 'Own'])
|
| 71 |
# Add download button for template
|
| 72 |
st.download_button(
|
| 73 |
label="Template",
|
|
|
|
| 52 |
elif sport_var == "MLB":
|
| 53 |
st.info("upload a projections file that has Data oriented in the following format: 'Player', 'Team', 'Opp', 'Position', 'Salary', 'Median', 'Minutes', 'Own'")
|
| 54 |
elif sport_var == "MMA":
|
| 55 |
+
st.info("upload a projections file that has Data oriented in the following format: 'Player', 'Salary', 'Median', 'KO Odds', 'Submission Odds', 'Own'")
|
| 56 |
# Create two columns for the uploader and template button
|
| 57 |
upload_col, template_col = st.columns([3, 1])
|
| 58 |
|
|
|
|
| 67 |
elif sport_var == "MLB":
|
| 68 |
template_df = pd.DataFrame(columns=['Player', 'Team', 'Opp', 'Position', 'Salary', 'Median', 'Minutes', 'Own'])
|
| 69 |
elif sport_var == "MMA":
|
| 70 |
+
template_df = pd.DataFrame(columns=['Player', 'Salary', 'Median', 'KO_var', 'Sub_var', 'Own'])
|
| 71 |
# Add download button for template
|
| 72 |
st.download_button(
|
| 73 |
label="Template",
|
function_hold/MMA_functions.py
CHANGED
|
@@ -7,11 +7,20 @@ from pandas import concat as pd_concat
|
|
| 7 |
from pandas import merge as pd_merge
|
| 8 |
from pandas import DataFrame
|
| 9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
def DK_MMA_ROO_Build(projections_file, std_var, distribution_type):
|
| 11 |
total_sims = 1000
|
| 12 |
|
| 13 |
projects_raw = projections_file.copy()
|
| 14 |
projects_raw = projects_raw.replace("", np_nan)
|
|
|
|
|
|
|
|
|
|
| 15 |
dk_df = projects_raw.sort_values(by='Median', ascending=False)
|
| 16 |
|
| 17 |
basic_own_df = dk_df.copy()
|
|
@@ -104,9 +113,9 @@ def DK_MMA_ROO_Build(projections_file, std_var, distribution_type):
|
|
| 104 |
|
| 105 |
flex_file = basic_own_df[['Player', 'Salary', 'Median', 'KO_var']]
|
| 106 |
flex_file = flex_file.rename(columns={"Agg": "Median"})
|
| 107 |
-
flex_file['Median'] = flex_file['Median'] - (flex_file['Median'] * (flex_file['
|
| 108 |
-
flex_file['Floor'] = flex_file['Median'] * (1-flex_file['
|
| 109 |
-
flex_file['Ceiling'] = flex_file['Median'] * (1+flex_file['
|
| 110 |
flex_file['STD'] = (flex_file['Median'] / std_var)
|
| 111 |
flex_file = flex_file[['Player', 'Salary', 'Floor', 'Median', 'Ceiling', 'STD']]
|
| 112 |
flex_file = flex_file.reset_index(drop=True)
|
|
@@ -231,6 +240,8 @@ def FD_MMA_ROO_Build(projections_file, std_var, distribution_type):
|
|
| 231 |
total_sims = 1000
|
| 232 |
|
| 233 |
projects_raw = projections_file.copy()
|
|
|
|
|
|
|
| 234 |
fd_df = projects_raw.sort_values(by='Median', ascending=False)
|
| 235 |
|
| 236 |
basic_own_df = fd_df.copy()
|
|
@@ -323,9 +334,9 @@ def FD_MMA_ROO_Build(projections_file, std_var, distribution_type):
|
|
| 323 |
|
| 324 |
flex_file = basic_own_df[['Player', 'Salary', 'Median', 'KO_var']]
|
| 325 |
flex_file = flex_file.rename(columns={"Agg": "Median"})
|
| 326 |
-
flex_file['Median'] = flex_file['Median'] - (flex_file['Median'] * (flex_file['
|
| 327 |
-
flex_file['Floor'] = flex_file['Median'] * (1-flex_file['
|
| 328 |
-
flex_file['Ceiling'] = flex_file['Median'] * (1+flex_file['
|
| 329 |
flex_file['STD'] = (flex_file['Median'] / std_var)
|
| 330 |
flex_file = flex_file[['Player', 'Salary', 'Floor', 'Median', 'Ceiling', 'STD']]
|
| 331 |
flex_file = flex_file.reset_index(drop=True)
|
|
|
|
| 7 |
from pandas import merge as pd_merge
|
| 8 |
from pandas import DataFrame
|
| 9 |
|
| 10 |
+
def moneyline_to_probability(moneyline):
|
| 11 |
+
if moneyline > 0:
|
| 12 |
+
return 100 / (moneyline + 100)
|
| 13 |
+
else:
|
| 14 |
+
return abs(moneyline) / (abs(moneyline) + 100)
|
| 15 |
+
|
| 16 |
def DK_MMA_ROO_Build(projections_file, std_var, distribution_type):
|
| 17 |
total_sims = 1000
|
| 18 |
|
| 19 |
projects_raw = projections_file.copy()
|
| 20 |
projects_raw = projects_raw.replace("", np_nan)
|
| 21 |
+
projects_raw['range_initial'] = (projects_raw['KO_var'] + projects_raw['Sub_var']) / 2
|
| 22 |
+
projects_raw['range_var'] = projects_raw['range_initial'].apply(moneyline_to_probability)
|
| 23 |
+
|
| 24 |
dk_df = projects_raw.sort_values(by='Median', ascending=False)
|
| 25 |
|
| 26 |
basic_own_df = dk_df.copy()
|
|
|
|
| 113 |
|
| 114 |
flex_file = basic_own_df[['Player', 'Salary', 'Median', 'KO_var']]
|
| 115 |
flex_file = flex_file.rename(columns={"Agg": "Median"})
|
| 116 |
+
flex_file['Median'] = flex_file['Median'] - (flex_file['Median'] * (flex_file['range_var']-.5))
|
| 117 |
+
flex_file['Floor'] = flex_file['Median'] * (1-flex_file['range_var'])
|
| 118 |
+
flex_file['Ceiling'] = flex_file['Median'] * (1+flex_file['range_var'])
|
| 119 |
flex_file['STD'] = (flex_file['Median'] / std_var)
|
| 120 |
flex_file = flex_file[['Player', 'Salary', 'Floor', 'Median', 'Ceiling', 'STD']]
|
| 121 |
flex_file = flex_file.reset_index(drop=True)
|
|
|
|
| 240 |
total_sims = 1000
|
| 241 |
|
| 242 |
projects_raw = projections_file.copy()
|
| 243 |
+
projects_raw['range_initial'] = (projects_raw['KO_var'] + projects_raw['Sub_var']) / 2
|
| 244 |
+
projects_raw['range_var'] = projects_raw['range_initial'].apply(moneyline_to_probability)
|
| 245 |
fd_df = projects_raw.sort_values(by='Median', ascending=False)
|
| 246 |
|
| 247 |
basic_own_df = fd_df.copy()
|
|
|
|
| 334 |
|
| 335 |
flex_file = basic_own_df[['Player', 'Salary', 'Median', 'KO_var']]
|
| 336 |
flex_file = flex_file.rename(columns={"Agg": "Median"})
|
| 337 |
+
flex_file['Median'] = flex_file['Median'] - (flex_file['Median'] * (flex_file['range_var']-.5))
|
| 338 |
+
flex_file['Floor'] = flex_file['Median'] * (1-flex_file['range_var'])
|
| 339 |
+
flex_file['Ceiling'] = flex_file['Median'] * (1+flex_file['range_var'])
|
| 340 |
flex_file['STD'] = (flex_file['Median'] / std_var)
|
| 341 |
flex_file = flex_file[['Player', 'Salary', 'Floor', 'Median', 'Ceiling', 'STD']]
|
| 342 |
flex_file = flex_file.reset_index(drop=True)
|