-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathminer_dashboard.py
More file actions
46 lines (29 loc) · 1.53 KB
/
miner_dashboard.py
File metadata and controls
46 lines (29 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
from retrieve_data import get_data, scale_data, prep_pred_input
from model import load_or_run_model
from retrieve_data import update_current_team_database
import numpy as np
def activate():
data = get_data()
scalers, X_scaled, y_scaled = scale_data(data)
model = load_or_run_model(scalers, X_scaled, y_scaled)
### This is where the new predictions will get read in ###
list_of_fixtures = [
{'DATE': '2024-09-06', 'HT': 'Kansas City Chiefs', 'AT' : 'Baltimore Ravens'},
{'DATE': '2024-09-07', 'HT': 'Philadelphia Eagles', 'AT' : 'Green Bay Packers'}
]
for fixture in list_of_fixtures:
pred_input, hist_score = prep_pred_input(fixture, scalers)
predicted_outcome = model.predict(pred_input)
home_pred_unrounded = scalers['HT_SC'].inverse_transform(predicted_outcome[:, 0].reshape(-1, 1))[0][0]
away_pred_unrounded = scalers['AT_SC'].inverse_transform(predicted_outcome[:, 1].reshape(-1, 1))[0][0]
home_pred = round(home_pred_unrounded)
away_pred = round(away_pred_unrounded)
if home_pred == away_pred and home_pred_unrounded > away_pred_unrounded:
away_pred -= 1
elif home_pred == away_pred and home_pred_unrounded < away_pred_unrounded:
home_pred -= 1
print(fixture['HT'], ':', fixture['AT'], ' predicted score... ', home_pred, ':', away_pred, 'actual score :', hist_score)
activate()
def update_current_data():
update_current_team_database()
print('Ready to create new predictions.')