Spaces:
Running
Running
Commit
·
ee27188
1
Parent(s):
fd567de
Dynamic week switching
Browse files- Source/Predict/predict.py +3 -3
- main.py +1 -1
Source/Predict/predict.py
CHANGED
@@ -48,10 +48,10 @@ def get_week():
|
|
48 |
return int(week), int(year)
|
49 |
|
50 |
|
51 |
-
def get_games():
|
52 |
# pull from NBC
|
53 |
url = 'https://www.nbcsports.com/nfl/schedule'
|
54 |
-
df = pd.read_html(url)[
|
55 |
df['Away Team'] = [' '.join(i.split('\xa0')[1:]) for i in df['Away TeamAway Team']]
|
56 |
df['Home Team'] = [' '.join(i.split('\xa0')[1:]) for i in df['Home TeamHome Team']]
|
57 |
df['Date'] = pd.to_datetime(df['Game TimeGame Time'])
|
@@ -120,7 +120,7 @@ def predict(home,away,season,week,total):
|
|
120 |
'Result': moneyline_result}
|
121 |
|
122 |
# over/under
|
123 |
-
model = '
|
124 |
file_path = os.path.join(model_directory, f'{model}.json')
|
125 |
xgb_ou = xgb.Booster()
|
126 |
xgb_ou.load_model(file_path)
|
|
|
48 |
return int(week), int(year)
|
49 |
|
50 |
|
51 |
+
def get_games(week):
|
52 |
# pull from NBC
|
53 |
url = 'https://www.nbcsports.com/nfl/schedule'
|
54 |
+
df = pd.read_html(url)[week-1]
|
55 |
df['Away Team'] = [' '.join(i.split('\xa0')[1:]) for i in df['Away TeamAway Team']]
|
56 |
df['Home Team'] = [' '.join(i.split('\xa0')[1:]) for i in df['Home TeamHome Team']]
|
57 |
df['Date'] = pd.to_datetime(df['Game TimeGame Time'])
|
|
|
120 |
'Result': moneyline_result}
|
121 |
|
122 |
# over/under
|
123 |
+
model = 'xgboost_OU_no_odds_59.8%'
|
124 |
file_path = os.path.join(model_directory, f'{model}.json')
|
125 |
xgb_ou = xgb.Booster()
|
126 |
xgb_ou.load_model(file_path)
|
main.py
CHANGED
@@ -16,7 +16,7 @@ week, season = predict.get_week()
|
|
16 |
app = Flask(__name__, template_folder="Templates", static_folder="Static", static_url_path="/Static")
|
17 |
app.secret_key = 'green-flounder'
|
18 |
|
19 |
-
games = predict.get_games()[['Date','Away Team','Home Team']]
|
20 |
|
21 |
@app.route('/')
|
22 |
def index():
|
|
|
16 |
app = Flask(__name__, template_folder="Templates", static_folder="Static", static_url_path="/Static")
|
17 |
app.secret_key = 'green-flounder'
|
18 |
|
19 |
+
games = predict.get_games(week)[['Date','Away Team','Home Team']]
|
20 |
|
21 |
@app.route('/')
|
22 |
def index():
|