predict_game_teamwins() loads the saved model from models/nba_model.pkl and returns a win probability between 0 and 1 for a given set of rolling team statistics.
The model must be trained before calling this function. Run
train_model_teamwins() first.Function signature
float — win probability between 0.0 and 1.0.
Parameters
Rolling average points differential — the team’s average points per game minus the opponent’s, computed over the last several games.
The team’s rolling average rebounds per game.
The opponent’s rolling average rebounds per game.
The team’s rolling average assists per game.
The opponent’s rolling average assists per game.
1 if the team is playing at home, 0 if the team is playing away.Usage examples
The examples below are drawn frommain.py and test_betting.py.
Even match (from main.py)
A team with no points advantage, slightly weaker rebounding and assists, playing at home:Strong home favorite
A team with a clear statistical edge and home court advantage:Slight underdog
A team trailing in most metrics and playing away:How it works
Internally, the function constructs a single-rowDataFrame from the six inputs, then calls predict_proba on the loaded model:
predict_proba(features)[0][1] returns the probability assigned to class 1 (win).