2 Commits

Author SHA1 Message Date
ramseshk aad4ee8cf6 Add ML dashboard panel, paper trader, time decay model
- /api/ml endpoint: per-model raw vs calibrated, typhoon, spatial features
- ML Predictions card in web dashboard (color-coded, sorted by confidence)
- Typhoon Probabilities card (T1/T3/T8 now/72h/120h)
- PaperTrader: simulated trading with portfolio Kelly, P&L tracking,
  trade history persistence, auto-resolution after 24h
- TimeDecayModel: theta decay for binary options
  sigma(t) = sigma_0 * (T-t)^beta (beta=0.4 for weather)
  Fair price convergence from 50%→model_prob as expiry approaches
- Paper trader CLI: --track (monitor), --report, --simulate-days

Run dashboard: python web_dashboard.py  # see ML panel
Run paper:  python ml/paper_trader.py --simulate-days 30
2026-08-11 11:15:43 +08:00
ramseshk 11182b47f8 Fix ML calibration: logistic regression + Platt/isotonic + realistic NWP errors
Calibration overhaul:
- Logistic regression mode for synthetic/bootstrap data (prevents LightGBM overfit)
- 3-layer calibration stack: raw LR → Platt scaling → isotonic regression
- Extreme probability smoothing: blend toward 0.5 when raw>0.95 or raw<0.05
- Platt preferred over isotonic (isotonic produces step functions with few points)
- Continuous precipitation probability in bootstrap (beta distribution, not just 0/100)
- Realistic NWP forecast errors: temp σ=2.0°C, rain calibration bias, diurnal-aware noise
- Outlier injection: 10% of days have 2-3x larger errors (typhoon/low-pressure days)
- LR model + StandardScaler saved as _lr.pkl alongside .lgb marker

Results:
- temp_gt_30c: AUC=0.987, Brier=0.049, predictions vary 20-85% per day
- rain_gt_0mm: AUC=0.979, Brier=0.042, predictions vary 15-85% per day
- temp_gt_35c: AUC=0.713 (realistic — extreme heat is hard to predict)
2026-08-11 10:50:05 +08:00