How do you implement ML model monitoring and detect data drift in production?
Model monitoring ensures ML models continue performing well after deployment. Monitoring dimensions: data drift (input data distribution changes from training data), concept drift (relationship between inputs and outputs changes), model performance degradation (accuracy/F1 declining over time), and operational metrics (latency, throughput, error rates). Data drift detection: statistical tests comparing production data to training data distributions. For numerical features: Kolmogorov-Smirnov test, Population Stability Index (PSI), or Wasserstein distance. For categorical features: chi-squared test or Jensen-Shannon divergence. Implement per-feature monitoring with alerting thresholds. Concept drift detection: requires ground truth labels (which may arrive with delay). Track prediction confidence distribution, monitor performance metrics as labels become available, and implement windowed performance tracking. Implementation: use monitoring frameworks (Evidently AI, WhyLabs, Arize AI, or custom Grafana dashboards). Pipeline: log all predictions with input features, aggregate metrics at regular intervals (hourly, daily), compute drift statistics against reference distributions, and alert when thresholds are exceeded. Reference data management: maintain a reference dataset representing the training data distribution, update reference after intentional model retraining, and version reference data alongside model versions. Retraining triggers: automated retraining when drift exceeds threshold, scheduled retraining (weekly/monthly as a safety net), and manual retraining triggered by performance alerts. A/B testing: when deploying updated models, split traffic and compare performance before full rollout. Dashboard: display real-time prediction distributions, feature drift indicators, model performance trends, and data quality metrics.