Flask web app for exploring historical Cash Pot–style draw data with Random Forest and LSTM (TensorFlow) models, plus frequency/pattern heuristics. Draw scheduling follows the Jamaica timetable (six daily draws, excluding Christmas and Good Friday).
Disclaimer: This project is for learning and experimentation only. Past draws do not predict future outcomes. Do not use this as financial or gambling advice.
- Dashboard — Stats, recent predictions, accuracy summary, optional startup training banner, model health / monitor hooks
- Predictions — Multiple methods (e.g. LSTM, Random Forest, frequency, patterns, ensemble/auto with governance hooks)
- Data — CSV upload, single-draw entry, edit/delete draws
- History — Paginated draw history and prediction history; relink predictions to draws
- Retraining — Async
/retrainwith/api/training_statusfor UI feedback - Backtesting & benchmarks — Walk-forward backtest, multi-seed evaluation, benchmark baseline/history, profile presets (
quick/standard/deep) - APIs — JSON endpoints for stats, draws, backtest, benchmark evaluate/history, monitor health, model/training status
| Layer | Choice |
|---|---|
| Web | Flask 2.x |
| Data | SQLite (via DatabaseManager in models.py) |
| ML | scikit-learn (Random Forest), TensorFlow 2.13 (LSTM softmax + calibration) |
| Deploy-friendly | gunicorn in requirements.txt |
- Python 3.10+ recommended (TensorFlow 2.13 is picky on version; use a version that matches your platform)
- System dependencies as required by TensorFlow on your OS
cd "Gambling App" # or your clone path
python3 -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -r requirements.txt| Variable | Default | Purpose |
|---|---|---|
ENABLE_STARTUP_TRAINING |
1 |
If 0, skip training models when the app starts (faster dev; use Retrain in UI/API instead) |
Production: Set a real Flask secret_key in app.py or via env/config — do not ship the placeholder.
- SQLite file:
lottery_data.db(created when you first run the app). Listed in.gitignore— not committed by default. - Trained artifacts may live under
trained_models/(add to.gitignoreif you do not want them in Git).
source .venv/bin/activate
python3 app.pyOpen the URL shown in the terminal (often http://127.0.0.1:5000).
Production-style (example):
gunicorn -w 2 -b 0.0.0.0:8080 app:app| Path | Role |
|---|---|
app.py |
Routes, training thread state, benchmark profiles |
models.py |
SQLite schema, draws, predictions, benchmarks |
predictor.py |
LotteryPredictor — methods, ensemble, backtests |
ml_trainer.py |
LSTM training/inference, RF helper |
schedule.py |
Jamaica draw times & blackout dates |
templates/ |
HTML pages |
static/ |
CSS/JS |
| Method | Path | Notes |
|---|---|---|
| GET | / |
Dashboard |
| POST | /predict |
JSON prediction |
| GET/POST | /upload, /add_single, … |
Data management |
| GET | /history, /prediction-history |
Paginated views |
| POST | /retrain |
Trigger retrain (background) |
| GET | /api/training_status, /api/model_status |
Training / model state |
| GET | /api/backtest, /api/backtest_multi |
Backtest JSON |
| GET/POST | /api/benchmark/* |
Baseline, evaluate, history |
| GET | /api/monitor/health |
Lightweight health JSON |
Specify your license here (e.g. MIT) if you want the repo to be open source.
loukieluke — MachineLearning