🏀 NBA Game Predictor (XGBoost)
A machine learning model for predicting NBA game outcomes and identifying value bets by comparing model predictions to betting market odds.
Model Description
This model uses an XGBoost classifier trained on historical NBA game data to predict home team win probability. It's designed for value bet detection — comparing model probabilities to sportsbook implied odds to find +EV (positive expected value) betting opportunities.
Performance
| Metric | Value |
|---|---|
| Test Accuracy | 57.4% |
| Cross-Val Accuracy | 60.5% (±1.5%) |
Features
The model uses 11 engineered features:
home_win_pct/away_win_pct— Win percentageshome_ppg/away_ppg— Points per gamehome_opp_ppg/away_opp_ppg— Opponent points per gamehome_point_diff/away_point_diff— Average point differentialwin_pct_diff— Win percentage differencepoint_diff_diff— Point differential differencehome_advantage— Home court advantage factor
Usage
import joblib
import pandas as pd
# Load model
model = joblib.load('model.pkl')
# Prepare features
features = pd.DataFrame([{
'home_win_pct': 0.65,
'away_win_pct': 0.45,
'home_ppg': 115.0,
'away_ppg': 110.0,
'home_opp_ppg': 108.0,
'away_opp_ppg': 113.0,
'home_point_diff': 7.0,
'away_point_diff': -3.0,
'win_pct_diff': 0.20,
'point_diff_diff': 10.0,
'home_advantage': 0.03
}])
# Predict win probability
probs = model.predict_proba(features)
home_win_prob = probs[0][1]
away_win_prob = probs[0][0]
print(f"Home win probability: {home_win_prob:.1%}")
print(f"Away win probability: {away_win_prob:.1%}")
Value Bet Detection
The model pairs with Kelly Criterion bet sizing for value bet identification:
- Convert sportsbook odds to implied probability
- Compare to model's predicted probability
- If model probability > implied probability → positive edge (+EV)
- Kelly Criterion determines optimal bet size based on edge
Live Demo
Interactive dashboard available at: ianalloway/sports-betting-ml
Training Data
The model was trained on 2,000 simulated NBA games using realistic team strength ratings. In production, this would use live data from the NBA API.
Author
Ian Alloway — GitHub · Twitter · LinkedIn · Portfolio
License
MIT License