https://github.com/zients/tw-lottery-recommandation
Taiwan lottery draw analyzer & number recommender with Transformer ML model. Supports 539, 649, 638, 3D, and 4D lotteries.
https://github.com/zients/tw-lottery-recommandation
cli data-analysis lottery machine-learning python pytorch taiwan transformer
Last synced: about 1 month ago
JSON representation
Taiwan lottery draw analyzer & number recommender with Transformer ML model. Supports 539, 649, 638, 3D, and 4D lotteries.
- Host: GitHub
- URL: https://github.com/zients/tw-lottery-recommandation
- Owner: zients
- License: mit
- Created: 2026-04-07T15:27:41.000Z (2 months ago)
- Default Branch: main
- Last Pushed: 2026-05-03T05:25:47.000Z (about 2 months ago)
- Last Synced: 2026-05-03T06:34:57.966Z (about 1 month ago)
- Topics: cli, data-analysis, lottery, machine-learning, python, pytorch, taiwan, transformer
- Language: Python
- Size: 112 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# tw-lottery-recommandation
Taiwan lottery draw analyzer & number recommender with a Transformer ML model. Supports multiple lottery types.
Data source: [Taiwan Lottery official API](https://api.taiwanlottery.com)
## Supported Lotteries
| `--type` | Name | Format |
|----------|------|--------|
| `539` | Daily 539 | Pick 5, range 1–39 |
| `649` | Lotto 649 | Pick 6, range 1–49 |
| `638` | Super Lotto 638 | Pick 6 (1–38) + bonus ball (1–8) |
| `3d` | 3D Lottery | 3 digits, 0–9 |
| `4d` | 4D Lottery | 4 digits, 0–9 |
## Installation
```bash
uv sync
```
## Usage
### Update draw data
```bash
uv run lottery update --type 539 # continues from latest DB record, or fetches from the beginning
uv run lottery update --type 649 --from-month 2024-01 # specify a start month
```
### Statistics
```bash
uv run lottery stats --type 539
```
Output:
- Top 10 most frequent numbers (all-time)
- Hot / cold numbers (last 30 draws)
- Bonus ball frequency Top 5 (638 only)
### Number recommendation
```bash
uv run lottery recommend --type 638
```
Generates 3 recommended combinations based on:
- Historical frequency (top 20 candidates)
- Odd/even ratio and sum range filters (539 / 649 / 638)
- Bonus ball recommendation (638 only)
- Transformer ML model when a trained checkpoint is available
### Train ML model
```bash
uv run lottery train --type 539 --epochs 100
```
Trains a Transformer model and saves the best checkpoint to `ml/checkpoints/`. Once trained, `recommend` will automatically use ML predictions.
### Run tests
```bash
uv run pytest
```