Closed madmax01 closed 1 year ago
python3 main.py -xgb -odds=fanduel
this is just xgboost model Predictions.
tried to get "-A" working with including the Neural Network...
when doing
python3 main.py -nn -odds=fanduel (its same error).
was this option removed or so?
The option was not removed, it's working fine for me.
What repo/branch are you running?
Are you running in Google Colab or local?
i used this locally "not google colab"
https://github.com/kyleskom/NBA-Machine-Learning-Sports-Betting.git
and tried then to run python3 main.py -A -odds=fanduel
so to have the xgboost and neural check.
anything i miss here? ;)
What commit are you on?
git rev-parse HEAD
i just downloaded the zip and done. assuming zip is based on master? ;)
python -m Get_Data python -m Create_Games
cd ../Train-Models python -m XGBoost_Model_ML python -m XGBoost_Model_UO
and python3 main.py -A -odds=fanduel
git rev-parse HEAD "0339624c68948c23e257f2105f51f88753d93b25"
out of date. do a git pull or download the latest zip
i downloaded the latest zip.
how can i do git update after downloaded zip?
just git pull. thats it?
remote: Enumerating objects: 19, done. remote: Counting objects: 100% (19/19), done. remote: Compressing objects: 100% (10/10), done. remote: Total 19 (delta 9), reused 17 (delta 9), pack-reused 0 Unpacking objects: 100% (19/19), 1.71 MiB | 3.82 MiB/s, done. From https://github.com/kyleskom/NBA-Machine-Learning-Sports-Betting 0339624c..d5300ac1 master -> origin/master error: Your local changes to the following files would be overwritten by merge: src/Utils/tools.py Please commit your changes or stash them before you merge. Aborting Updating 0339624c..d5300ac1
it says 0339624c68948c23e257f2105f51f88753d93b25
ah i done a stash and pull again now
d5300ac15b0f0ed0d3b861def9bafd99ba205403
seems updated 3h ago.
but still getting for NN_Runner.py following error
the AttributeError: '_UserObject' object has no attribute 'predict'
may any hint what i need to fix here?
In NN_Runner, its pulling the models from "Models/NN_Models/Trained-Model-ML" and "Models/NN_Models/Trained-Model-OU", which hasnt been generated because you generated XGBoost data instead with the commands "python -m XGBoost_Model_ML" and "python -m XGBoost_Model_UO". However I dont see any way to generate the NN models in the code
i did run now python -m and each below
src\Trained-Models\Train_model src\Trained-Models\Train_model_UO
but seems still same error... not finding an info in the Documentation how to deal with the keras
tried to add bit debug
`import copy import numpy as np import pandas as pd import tensorflow as tf from colorama import Fore, Style, init, deinit from tensorflow.keras.models import load_model from src.Utils import Expected_Value
init()
try: model = load_model('Models/NN_Models/Trained-Model-ML') ou_model = load_model("Models/NN_Models/Trained-Model-OU") except OSError as e: print(f"Failed to load model file: {e}") raise SystemExit(1)
if not isinstance(model, tf.keras.models.Model): print("Loaded model is not a Keras model") raise SystemExit(1)
def nn_runner(data, todays_games_uo, frame_ml, games, home_team_odds, away_team_odds): ml_predictions_array = []
for row in data:
ml_predictions_array.append(model.predict(np.array([row])))
frame_uo = copy.deepcopy(frame_ml)
frame_uo['OU'] = np.asarray(todays_games_uo)
data = frame_uo.values
data = data.astype(float)
data = tf.keras.utils.normalize(data, axis=1)
ou_predictions_array = []
for row in data:
ou_predictions_array.append(ou_model.predict(np.array([row])))
count = 0
for game in games:
home_team = game[0]
away_team = game[1]
winner = int(np.argmax(ml_predictions_array[count]))
under_over = int(np.argmax(ou_predictions_array[count]))
winner_confidence = ml_predictions_array[count]
un_confidence = ou_predictions_array[count]
if winner == 1:
winner_confidence = round(winner_confidence[0][1] * 100, 1)
if under_over == 0:
un_confidence = round(ou_predictions_array[count][0][0] * 100, 1)
print(Fore.GREEN + home_team + Style.RESET_ALL + Fore.CYAN + f" ({winner_confidence}%)" + Style.RESET_ALL + ' vs ' + Fore.RED + away_team + Style.RESET_ALL + ': ' +
Fore.MAGENTA + 'UNDER ' + Style.RESET_ALL + str(todays_games_uo[count]) + Style.RESET_ALL + Fore.CYAN + f" ({un_confidence}%)" + Style.RESET_ALL)
else:
un_confidence = round(ou_predictions_array[count][0][1] * 100, 1)
print(Fore.GREEN + home_team + Style.RESET_ALL + Fore.CYAN + f" ({winner_confidence}%)" + Style.RESET_ALL + ' vs ' + Fore.RED + away_team + Style.RESET_ALL + ': ' +
Fore.BLUE + 'OVER ' + Style.RESET_ALL + str(todays_games_uo[count]) + Style.RESET_ALL + Fore.CYAN + f" ({un_confidence}%)" + Style.RESET_ALL)
else:
winner_confidence = round(winner_confidence[0][0] * 100, 1)
if under_over == 0:
un_confidence = round(ou_predictions_array[count][0][0] * 100, 1)
print(Fore.RED + home_team + Style.RESET_ALL + ' vs ' + Fore.GREEN + away_team + Style.RESET_ALL + Fore.CYAN + f" ({winner_confidence}%)" + Style.RESET_ALL + ': ' +
Fore.MAGENTA + 'UNDER ' + Style.RESET_ALL + str(todays_games_uo[count]) + Style.RESET_ALL + Fore.CYAN + f" ({un_confidence}%)" + Style.RESET_ALL)
else:
un_confidence = round(ou_predictions_array[count][0][1] * 100, 1)
print(Fore.RED + home_team + Style.RESET_ALL + ' vs ' + Fore.GREEN + away_team + Style.RESET_ALL + Fore.CYAN + f" ({winner_confidence}%)" + Style.RESET_ALL + ': ' +
Fore.BLUE + 'OVER ' + Style.RESET_ALL + str(todays_games_uo[count]) + Style.RESET_ALL + Fore.CYAN + f" ({un_confidence}%)" + Style.RESET_ALL)
count += 1
print("--------------------Expected Value---------------------")
count = 0
for game in games:
home_team = game[0]
away_team = game[1]
ev_home = float(Expected_Value.expected_value(ml_predictions_array[count][0][1], int(home_team_odds[count])))
ev_away = float(Expected_Value.expected_value(ml_predictions_array[count][0][0], int(away_team_odds[count])))
if ev_home > 0:
print(home_team + ' EV: ' + Fore.GREEN + str(ev_home) + Style.RESET_ALL)
else:
print(home_team + ' EV: ' + Fore.RED + str(ev_home) + Style.RESET_ALL)
if ev_away > 0:
print(away_team + ' EV: ' + Fore.GREEN + str(ev_away) + Style.RESET_ALL)
else:
print(away_team + ' EV: ' + Fore.RED + str(ev_away) + Style.RESET_ALL)
count += 1
deinit()`
if i do that > it tells "Loaded model is not a Keras model"
may the Loading process is not correct? xgboost load json but inside the NN folder are pb files
I also have the same error. I am on git rev-parse HEAD: b07e8c5150d2c9b0b34696a2436a9703ee2d32eb, when I try to do a git pull it says "Already up to date". I use python 3.10.10, tensorflow 2.11.0 and keras 2.11.0. I tried to fix it myself but got to a point where I dont get further. Maybe someone knows how to solve that issue.
NBA-Machine-Learning-Sports-Betting\src\Predict\NN_Runner.py", line 18, in nn_runner ml_predictions_array.append(model.predict(np.array([row]))) AttributeError: '_UserObject' object has no attribute 'predict'
I am also having issues with the latest version, AttributeError: '_UserObject' object has no attribute 'predict' I tried the second suggestion with no luck; https://stackoverflow.com/questions/68173923/error-userobject-object-has-no-attribute-predict I am running this locally with head: b07e8c5150d2c9b0b34696a2436a9703ee2d32eb Python 3.10.10 TF: 2.11.0 keras: 2.11.0
Try python 3.9
Sadly python 3.9 doesn´t solve the issue. Same problem as with 3.10
looks like this is happening with windows users maybe? does anybody using windows have it working?
Ive got this working on my windows machine with Pycharm. Take a look at the discussion tabs
on NN_Runner.py
Change
to
from tensorflow.python.keras.models import load_model
Also check if you're a UK user. Try the bookie as bet365 instead of fanduel.
Also had the issue: AttributeError: '_UserObject' object has no attribute 'predict'
I was able to solve it by training the model for Train_Model:
cd ../Train-Models python -m Train_Model python -m Train_Model_UO
Due to some reason, the file was not saved correctly, so I had to move the files from "Trained-Model-ML-1679137211.9821796" to the folder "Trained-Model-ML" and the same for "Trained-Model-OU-1679133914.0189226" to "Trained-Model-OU".
Then the error message disappears.
I ran both , python -m Train_Model & Train_Model_UO, and after moving over the folders into NN_Models this is working correctly for me on windows. Thanks!
hi, getting following Error when running
python3 main.py -A -odds=fanduel
Traceback (most recent call last): File "main.py", line 111, in
main()
File "main.py", line 100, in main
NN_Runner.nn_runner(data, todays_games_uo, frame_ml, games, home_team_odds, away_team_odds)
File "NBA-Machine-Learning-Sports-Betting\src\Predict\NN_Runner.py", line 18, in nn_runner
ml_predictions_array.append(model.predict(np.array([row])))
AttributeError: '_UserObject' object has no attribute 'predict'