Chapter 31 Key Takeaways: The Complete ML Betting Pipeline

Key Concepts

  1. Architecture First, Code Second: A production ML betting pipeline is not a single script but an interconnected system of components: data ingestion, feature store, model training, model serving, bet execution, risk management, and monitoring. Start with a well-structured monolith using clear module boundaries. Migrate to microservices only when scaling demands require independent deployment and fault isolation across components.

  2. Feature Store as the Central Hub: The feature store is the single source of truth for feature computation, versioning, and retrieval. It enforces two critical invariants: (a) features served at inference time are computed identically to those used during training, and (b) point-in-time queries guarantee no future data leakage during backtesting. Every feature must be versioned, and models must record which feature versions they were trained on.

  3. Model Registry and Lifecycle Management: Every trained model is registered with its metrics, feature dependencies, and configuration. The registry tracks which model is currently active for each sport, supports A/B testing between candidate models, and enables instant rollback when a new model underperforms. Never promote a model directly from training to production --- use shadow mode or a canary deployment to validate live performance first.

  4. Risk Management as an Independent Layer: Risk controls (maximum bet size, daily loss limits, correlated exposure limits, kill switches) must be enforced independently of the prediction model. The risk management layer is the last line of defense against catastrophic losses caused by model errors, data pipeline failures, or market anomalies. It should be the most resilient component in the system.

  5. Monitoring Wraps Around Everything: Every component in the pipeline must be instrumented for observability. Monitor data freshness, feature distribution drift (PSI), model prediction latency, calibration quality, daily P&L, and bet execution fill rates. Automated alerts should fire for anomalies at every layer. A betting pipeline that cannot detect its own failures is a pipeline that will eventually lose money without knowing why.

  6. Bet Execution Is an Engineering Problem: Converting a model prediction into a placed bet involves odds verification, position sizing via the Kelly criterion, slippage management, execution confirmation, and full audit trail logging. Bet execution must be atomic: either the bet is placed at acceptable odds, or it is not placed at all. Partial execution or stale-odds execution destroys edge.

  7. Scheduling and Orchestration: The pipeline operates on two timescales. Batch jobs (data ingestion, feature computation, model retraining) run on a scheduled cadence. Real-time components (prediction serving, odds monitoring, bet execution) run continuously. Failure in a batch job should not halt real-time components; the system falls back to the most recently computed valid state.


Key Formulas

Formula Expression Example
Kelly Criterion f* = (bp - q) / b p=0.58, q=0.42, b=1.0 (even odds): f* = (0.58 - 0.42)/1.0 = 0.16
Fractional Kelly f = fraction * f* Quarter Kelly with f*=0.16: f = 0.25 * 0.16 = 0.04
Expected Value EV = p * payout - q * stake p=0.55 at -110: EV = 0.55(100/110) - 0.45 = 0.05 per dollar
Brier Score BS = (1/N) * sum((p_i - y_i)^2) Perfect = 0, random coin flip = 0.25
Elo Expected Score E = 1 / (1 + 10^((R_b - R_a)/400)) R_a=1600, R_b=1500: E_a = 0.640
PSI (drift) sum((A_i - E_i) * ln(A_i/E_i)) PSI < 0.10 = no drift, > 0.25 = significant

Pipeline Decision Framework

When building or evaluating a production ML betting pipeline, work through this checklist:

Step 1 -- Define scope and constraints. What sports and markets will the system cover? What is the bankroll? What is the maximum acceptable daily loss? What is the latency requirement (pre-game only or live betting)?

Step 2 -- Build the data layer. Identify all data sources (odds APIs, statistics providers, injury feeds). Implement ingestion with retry logic, rate limiting, and schema validation. Store raw data with deduplication. Build or adopt a feature store with versioning and point-in-time retrieval.

Step 3 -- Build the model layer. Implement a training pipeline with time-series cross-validation. Build a model registry that tracks all models, their metrics, and their feature dependencies. Implement calibration (Platt scaling or isotonic regression). Deploy a serving endpoint with consistent feature retrieval.

Step 4 -- Build the execution layer. Implement Kelly criterion bet sizing with fractional Kelly. Build risk management as an independent enforcement layer. Implement odds verification before execution. Build a complete audit trail logging every prediction, decision, and execution.

Step 5 -- Build the monitoring layer. Instrument every component with metrics. Implement drift detection on features and model predictions. Set up alerts for data staleness, latency spikes, calibration degradation, and P&L thresholds. Build dashboards for daily review.

Step 6 -- Deploy and iterate. Start with a paper-trading phase where the system generates recommendations without placing real bets. Validate that predictions, feature computation, and risk management work correctly. Gradually transition to live betting with small bet sizes. Scale only after confidence in system reliability.

The core principle: A production ML betting system is an engineering system, not a research project. The model is often the least complex component. The reliability, correctness, and safety of the surrounding infrastructure --- data pipelines, feature stores, risk controls, monitoring --- determine whether the system survives contact with real markets.


Ready for Chapter 32? Self-Assessment Checklist

Before moving on to Chapter 32 ("Natural Language Processing for Betting"), confirm that you can do the following:

  • [ ] Describe the six major components of a production ML betting pipeline and their interactions
  • [ ] Implement a feature store with versioning and point-in-time retrieval
  • [ ] Build a model training pipeline with time-series cross-validation and calibration
  • [ ] Deploy a model serving endpoint using FastAPI or a similar framework
  • [ ] Implement Kelly criterion bet sizing with risk management constraints
  • [ ] Design a model registry with A/B testing support
  • [ ] Set up monitoring with drift detection, latency tracking, and alerting
  • [ ] Explain the difference between batch and real-time prediction architectures
  • [ ] Design a database schema for a complete betting audit trail
  • [ ] Implement a circuit breaker pattern for external API calls

If you can check every box with confidence, you are well prepared for Chapter 32. If any items feel uncertain, revisit the relevant sections of Chapter 31 or work through the corresponding exercises before proceeding.