{"id":31649298,"url":"https://github.com/preston-bernstein/nba-predictor","last_synced_at":"2026-05-01T21:33:58.276Z","repository":{"id":313400438,"uuid":"1050747706","full_name":"preston-bernstein/nba-predictor","owner":"preston-bernstein","description":"NBA game outcome predictor built with Python, pandas, and scikit-learn. Early baseline model using rolling team stats.","archived":false,"fork":false,"pushed_at":"2025-09-28T15:12:12.000Z","size":137,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-28T15:17:18.608Z","etag":null,"topics":["basketball","fastapi","machine-learning","sklearn","sports-analytics"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/preston-bernstein.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-04T21:55:33.000Z","updated_at":"2025-09-28T15:12:15.000Z","dependencies_parsed_at":"2025-09-05T20:44:58.415Z","dependency_job_id":"8decbc10-4cbc-4547-b233-e9cf9efc7750","html_url":"https://github.com/preston-bernstein/nba-predictor","commit_stats":null,"previous_names":["preston-bernstein/nba-predictor"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/preston-bernstein/nba-predictor","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/preston-bernstein%2Fnba-predictor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/preston-bernstein%2Fnba-predictor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/preston-bernstein%2Fnba-predictor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/preston-bernstein%2Fnba-predictor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/preston-bernstein","download_url":"https://codeload.github.com/preston-bernstein/nba-predictor/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/preston-bernstein%2Fnba-predictor/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278740831,"owners_count":26037480,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-07T02:00:06.786Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["basketball","fastapi","machine-learning","sklearn","sports-analytics"],"created_at":"2025-10-07T07:42:01.051Z","updated_at":"2026-05-01T21:33:58.207Z","avatar_url":"https://github.com/preston-bernstein.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NBA predictor\n\n[![CI](https://github.com/preston-bernstein/nba-predictor/actions/workflows/ci.yaml/badge.svg?branch=main)](https://github.com/preston-bernstein/nba-predictor/actions/workflows/ci.yaml) [![Coverage](https://codecov.io/gh/preston-bernstein/nba-predictor/branch/main/graph/badge.svg)](https://codecov.io/gh/preston-bernstein/nba-predictor) [![Python](https://img.shields.io/badge/python-3.12-blue)](pyproject.toml) [![License](https://img.shields.io/badge/license-MIT-green)](LICENSE)\n\nPython 3.12 pipeline that scrapes Basketball-Reference, builds features, trains a classifier, and serves win probabilities through FastAPI. Cached CSVs in `data_cache/` and artifacts in `artifacts/` drive all predictions; refresh them with the pipeline before serving.\n\n## Setup\n\nCreate a virtual environment and install dev dependencies:\n\n```bash\npython -m venv .venv\nsource .venv/bin/activate\npython -m pip install -U pip\npython -m pip install -e '.[dev]'\n```\n\n## Pipeline\n\nRun everything end to end:\n\n```bash\nmake pipeline\n```\n\nOr run each step:\n\n- Fetch: `make fetch` (or `python -m src.data.fetch --seasons \"2024 2025\"`) → `data_cache/games.csv`.\n- Features: `make features` → rolling form, rest days, and Elo deltas in `data_cache/features.csv`.\n- Train: `make train MODELS=\"logreg rf\"` → best model at `artifacts/model.joblib` with metrics in `artifacts/metrics.json`.\n\nUse `OFFLINE=1` to seed from fixtures. Add `PRESERVE=1` to keep existing caches. Control seasons and model lists with `SEASONS` and `MODELS`.\n\n## API\n\nStart the service:\n\n```bash\nmake serve\n# uvicorn src.service.app:app --reload --port 5000\n```\n\nEndpoints:\n\n- `GET /v1/health` → `{\"ok\": true}`\n- `GET /v1/teams` → canonical team codes from cached games\n- `GET /v1/predict?home=NYK\u0026away=BOS\u0026date=2025-01-01` → win probability and feature deltas\n\nTeam inputs accept codes, full names, and common aliases. Unknown teams return HTTP 422 with a clear message. The service reads artifacts only; regenerate them before deploying.\n\n## Tests and QA\n\nCommon checks:\n\n```bash\nmake lint\nmake type\nmake test\nmake test-cov\nmake check          # fmt + lint + type + coverage gate\n```\n\nCoverage runs produce HTML and XML reports. Use `make cov-open`, `make test-cov-gaps`, or `make test-cov-diff` for deeper inspection.\n\n## Layout\n\n```\nsrc/\n  config.py           # path config for data and artifacts\n  data/               # scraping and feature engineering\n  model/              # training and model selection\n  service/            # FastAPI app, routes, schemas, normalizer\n  utils/              # logging helpers\ntests/                # unit and integration tests (fixtures included)\nartifacts/            # generated model + metrics\ndata_cache/           # generated games and features CSVs\nMakefile              # pipeline, QA, and serve targets\npyproject.toml        # deps and tooling config\n```\n\nData comes from Basketball-Reference. Treat `data_cache/` and `artifacts/` as generated outputs; rebuild them after code or schema changes.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpreston-bernstein%2Fnba-predictor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpreston-bernstein%2Fnba-predictor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpreston-bernstein%2Fnba-predictor/lists"}