Quiz 2

ML System Design

377 words
2 min read
Python Week 1: the first filter for runtime behavior
Visual companion
Python
Type and operator map

Python Week 1: the first filter for runtime behavior

View
Revision summary

What this note is really saying

Short form

# ML System Design ## 🎯 Learning Objectives - Design end-to-end ML systems for production - Choose between batch and real-time serving - Address data distribution shifts (monitoring, retraining) - Handle large-scale ML infrastructure decisions ## 📖 Core Content ### 9.1 ML System Components *(Diagram)* ### 9.2 Key...

ML System Design

🎯 Learning Objectives

  • Design end-to-end ML systems for production
  • Choose between batch and real-time serving
  • Address data distribution shifts (monitoring, retraining)
  • Handle large-scale ML infrastructure decisions

📖 Core Content

9.1 ML System Components

(Diagram)

9.2 Key Design Decisions

DecisionOption 1Option 2Tradeoff
ServingBatch (offline)Real-time (online)Latency vs recency
TrainingPeriodic retrainOnline learningFreshness vs stability
FeaturesPre-computedOn-the-flyStorage vs compute
ModelSingle modelEnsembleSimplicity vs accuracy
InfrastructureManaged (SageMaker)Custom (Kubernetes)Cost vs flexibility

9.3 Batch vs Real-time Serving

AspectBatchReal-time
LatencyHours to daysMilliseconds
Use CaseRecommendations (nightly)Fraud detection (instant)
ComputePredict all at oncePredict on-demand
CostLower (can schedule)Higher (always ON)
FreshnessStale (last batch)Current
ComplexitySimplerComplex (scaling, latency)

9.4 Model Monitoring

Drift types to monitor:
  • Data drift: Input distribution changes (customers get older)
  • Concept drift: Relationship between X and y changes (fashion trends)
  • Prediction drift: Output distribution changes
  • Target drift: Ground truth distribution changes Monitoring metrics:
  • Data distribution statistics (mean, std per feature)
  • Model performance (when labels available)
  • Prediction volume and latency
  • Feature importance over time

📝 Practice Questions

Q1: How would you design a real-time fraud detection system?
  1. Data pipeline: Kafka for transaction stream → feature computation in Flink
  2. Feature store: Redis for real-time features (user history, device fingerprints)
  3. Model: Lightweight ensemble (XGBoost + Neural Network) served via Docker on Kubernetes
  4. Inference: REST API with autoscaling (handle 10k QPS)
  5. Monitoring: Track prediction distribution, alert on drift, holdout for label feedback
  6. Retraining: Hourly retraining with latest confirmed fraud cases Q2: When would you choose batch serving over real-time?
Batch serving is better when: (1) predictions don't need to be instant (daily recommendations), (2) you need to process millions of predictions efficiently, (3) complex features require heavy computation, (4) cost is a primary concern. Example: Netflix generates recommendations nightly (batch) rather than recomputing every page load. Q3: What is the difference between data drift and concept drift?
Data drift: P(X) changes. The input distribution shifts but the relationship P(y|X) remains the same. Example: users become older (age distribution shifts) but age→purchase relationship unchanged. Concept drift: P(y|X) changes. The mapping from input to output changes. Example: what was fashionable last year (input) now predicts "unpopular" (output). Join Discord PreviousSemi-supervised LearningNextDeep Learning Basics
Document outline

Keep your place and jump directly to a heading.

Table of Contents
System Normal // Awaiting Context

Intelligence Hub

Navigate the knowledge graph to generate context. The Hub adapts dynamically to surface backlinks, related notes, and metadata insights.