Metadata-Version: 2.4
Name: wraith-tdf-predictor
Version: 0.12.0
Summary: Tour de France race outcome prediction: rider archetypes, a top-10 model, and Tissot fantasy team picks by exact knapsack.
Project-URL: Homepage, https://git.thomaspeoples.com/thomaspeoples/wraith-tdf-predictor
Project-URL: Website, https://thomaspeoples.com/tdf-predictor/
Project-URL: Repository, https://git.thomaspeoples.com/thomaspeoples/wraith-tdf-predictor.git
Project-URL: Documentation, https://www.thomaspeoples.com/gitea-repos/wraith-tdf-predictor/
Project-URL: Issues, https://git.thomaspeoples.com/thomaspeoples/wraith-tdf-predictor/issues
Project-URL: Changelog, https://git.thomaspeoples.com/thomaspeoples/wraith-tdf-predictor/src/branch/main/CHANGELOG.md
Author-email: Thomas Peoples <hello@thomaspeoples.com>
License: MIT License
        
        Copyright (c) 2026 Thomas Peoples
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: cycling,fantasy-cycling,prediction,tour-de-france
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.12
Requires-Dist: cloudscraper>=1.2.71
Requires-Dist: procyclingstats>=0.2.8
Provides-Extra: dev
Requires-Dist: commitizen; extra == 'dev'
Requires-Dist: detect-secrets; extra == 'dev'
Requires-Dist: genbadge[coverage]>=1.1.1; extra == 'dev'
Requires-Dist: mkdocs; extra == 'dev'
Requires-Dist: mkdocs-material; extra == 'dev'
Requires-Dist: mkdocstrings[python]; extra == 'dev'
Requires-Dist: poethepoet; extra == 'dev'
Requires-Dist: pre-commit; extra == 'dev'
Requires-Dist: pydoc-markdown; extra == 'dev'
Requires-Dist: pymdown-extensions; extra == 'dev'
Requires-Dist: pytest; extra == 'dev'
Requires-Dist: pytest-cov; extra == 'dev'
Requires-Dist: ruff; extra == 'dev'
Requires-Dist: ty; extra == 'dev'
Requires-Dist: typer; extra == 'dev'
Provides-Extra: scrape
Requires-Dist: playwright>=1.40; extra == 'scrape'
Description-Content-Type: text/markdown

# wraith-tdf-predictor 🚴💨

Who cracks the top 10 in July? Six seasons of ProCyclingStats results,
a from-scratch model, and a Tissot fantasy team picked by exact
knapsack — all in pure Python. No torch, no sklearn, no 200 MB wheel
for a model with nine weights.

The 2026 hot take so far: Pogačar. Groundbreaking stuff.

## What it does

- **Scrapes** grand tours, one-week stage races, monuments and top
  classics (men's elite, 2021–2026) into SQLite
- **Clusters** riders into archetypes with hand-rolled k-means
- **Predicts** top-10 finishes with class-weighted logistic regression
  (test AUC ~0.89 — form really is everything in cycling)
- **Picks** a 10-rider, 120-star Tissot fantasy team via 0/1 knapsack
  with cardinality, backtested leave-one-year-out against the
  hindsight-optimal team
- **Publishes** a static predictions page (`data.json`) with per-stage
  teams, jersey picks, and pred-vs-actual grading during the Tour

## Install

```bash
pip install wraith-tdf-predictor    # or: uv add wraith-tdf-predictor
```

Runtime dependencies: `procyclingstats` and `cloudscraper`. That's it.
Python 3.12+.

## Run it

From a clone:

```bash
git clone https://git.thomaspeoples.com/thomaspeoples/wraith-tdf-predictor.git
cd wraith-tdf-predictor
uv run poe setup      # deps, hooks, .env from template — once

uv run poe ingest     # scrape PCS -> data/raw/*.json (polite, cached)
uv run poe db         # load -> data/races.db (SQLite)
uv run poe model      # archetypes + top-10 model
uv run poe fantasy    # backtest + 2026 team pick
uv run poe publish    # data.json for the static predictions page
docker compose up -d  # browse the DB at :8080

uv run poe update     # daily during the Tour: ingest new stage if
                       # raced, retrain, republish -- no-op otherwise
```

Outputs land in `data/`: `archetypes.json`, `model.json`, and a
printed team that will absolutely not win your league.

## Configuration

Everything configurable lives in `.env` (copied from
[.env.example](.env.example) by `poe setup`, never committed):

| Variable | Default | Purpose |
|---|---|---|
| `DATA_DIR` | `./data` | Scraped data, SQLite DB, model outputs |
| `WWW_DIR` | `$DATA_DIR/www` | Where `poe publish` writes `data.json` |
| `TISSOT_USER` / `TISSOT_PASS` | — | Only for scraping the Tissot game yourself |

Poe tasks load `.env` automatically; direct `python -m` runs want
`uv run --env-file .env ...`.

Where the data comes from (and how politely it's scraped):
[docs/SOURCES.md](docs/SOURCES.md).

## Hacking on it

```bash
uv run poe test         # pytest, coverage >80% enforced
uv run poe tidy         # ruff lint + format
uv run poe docs-serve   # MkDocs on :8000
uv run cz commit        # commits go through commitizen, no exceptions
```

Full workflow in [CONTRIBUTING.md](CONTRIBUTING.md).

## License

MIT — see [LICENSE](LICENSE).
