Downloads · 30 days
0
heisenbergblue/nba-moneyline-xgboost
nba-moneyline-xgboost is a tabular classification model from heisenbergblue. Use it for the tabular classification task on the model card, and read the license before you ship it in a product. It is set up for xgboost. The card lists the license as mit.
Predicts the probability that the home team wins an NBA regular‑season game (the moneyline market) from both teams' season‑to‑date box‑score profiles. Trained and honestly validated with 5‑fold stratified cross‑valida…
Downloads · 30 days
0
Access
Public
Updated Jul 1, 2026
Repo size
—
Likes
0
Public
Click a slice to open those files.
.json935 KB · 99%
From the Hugging Face model README
Predicts the probability that the home team wins an NBA regular‑season game (the moneyline market) from both teams' season‑to‑date box‑score profiles. Trained and honestly validated with 5‑fold stratified cross‑validation — deliberately not the legacy "best of 300 random splits" trick.
🏀 Live demo: https://huggingface.co/spaces/heisenbergblue/nba-moneyline-predictor 🧩 Project: CrownWager · live at https://crownwager.vercel.app
⚠️ Informational only. Not financial or betting advice. 18+. Please bet responsibly.
| Task | Binary tabular classification — P(home win) |
| Algorithm | XGBoost (binary:logistic) — 750 trees, depth 3, lr 0.01 |
| Features | 106 (both teams' NBA season stats + days of rest) |
| Training data | ~15,100 NBA games, 2012–2024 |
| Framework | xgboost (native JSON booster) |
Numbers come from a fixed 20% hold‑out split and 5‑fold stratified cross‑validation — the training script explicitly rejects the legacy approach of cherry‑picking the best of many random splits.
| Metric | Value |
|---|---|
| CV accuracy (5‑fold) | 0.652 ± 0.008 |
| Hold‑out accuracy | 0.643 (n = 3,023) |
| ROC‑AUC | 0.685 |
| Log‑loss | 0.628 |
The historical home‑win base rate in the NBA is ~0.58–0.60, so "always pick home" scores around there; this model reaches ~0.64–0.65 while producing calibrated probabilities (ROC‑AUC 0.685) — which is what an expected‑value (+EV) workflow actually needs, more than raw accuracy.
| File | What |
|---|---|
xgboost_nba_ml.json | Trained XGBoost booster (native JSON) |
xgboost_nba_ml.features.json | Ordered list of the 106 feature columns |
xgboost_nba_ml.metrics.json | Evaluation metrics |
team_features.json | Per‑team latest season‑stat snapshot (to score new matchups by name) |
import json
import numpy as np
import xgboost as xgb
from huggingface_hub import hf_hub_download
REPO = "heisenbergblue/nba-moneyline-xgboost"
# Native booster API — no scikit-learn needed; for binary:logistic, predict() is P(home win)
booster = xgb.Booster()
booster.load_model(hf_hub_download(REPO, "xgboost_nba_ml.json"))
features = json.load(open(hf_hub_download(REPO, "xgboost_nba_ml.features.json")))
teams = json.load(open(hf_hub_download(REPO, "team_features.json")))
def home_win_probability(home: str, away: str) -> float:
h, a = teams[home], teams[away]
# away columns carry a ".1" suffix; everything else is the home side
vec = [(a.get(c[:-2], 0.0) if c.endswith(".1") else h.get(c, 0.0)) for c in features]
return float(booster.predict(xgb.DMatrix(np.array([vec], dtype=float)))[0])
print(home_win_probability("Boston Celtics", "Los Angeles Lakers"))
# List selectable teams with: sorted(teams)
Each game is encoded as a 106‑dimensional vector: the home team's season averages (games, win %,
shooting splits, rebounds, assists, turnovers, plus/minus, and league ranks) concatenated with the
away team's same stats (the .1 columns), plus each side's days of rest. team_features.json
stores every team's most recent snapshot, so you can score an upcoming matchup just by naming the two
teams.
Home-Team-Win (1 if the home team won).max_depth=3, learning_rate=0.01, n_estimators=750, subsample=0.9, colsample_bytree=0.9, objective="binary:logistic".ai/train/train_nba_ml.py in the CrownWager repo.MIT — the trained model is released for portfolio/educational use. The CrownWager application source is licensed separately.
Mubin Attar — AI/ML Engineer · GitHub @mubin-attar-007 · part of the CrownWager project.