Exams / DBX-MLP / D1 Drift Detection and Lakehouse Monitoring
Drift Detection and Lakehouse Monitoring
- Exam domain: Drift Detection and Lakehouse Monitoring
Types of drift
| Drift | What changes | Detected with |
|---|---|---|
| Feature (covariate) drift | Distribution of an input variable | Summary statistics, statistical tests, distances |
| Label drift | Distribution of the target variable | Compare label distributions over time |
| Prediction drift | Distribution of the model's predicted target | Compare prediction distributions |
| Concept drift | Relationship between inputs and target | Model-quality metric over time (needs ground truth), then a statistical test |
Concept-drift recipe: deploy and predict → obtain actual labels → compute the evaluation metric from observed and predicted values → run a statistical test on the metric over time.
Choosing a drift measure
| Need | Tool |
|---|---|
| Cheap, simple numeric check | Trends in summary statistics (mean, std, quantiles) |
| More robust numeric check | Statistical tests (e.g. KS test) |
| Categorical: is one value (e.g. missing) getting more common | One-way chi-squared (goodness of fit vs baseline counts) |
| Compare relative frequencies of a categorical variable across two periods | Jensen-Shannon distance |
JS distance is bounded and more stable on large datasets (KS becomes over-sensitive with large samples), but it gives no cutoff: you must pick a threshold manually. KS test: large statistic and small p-value = distributions differ.
Lakehouse Monitoring (data profiling)
Profile types: time series, inference, snapshot. Snapshot tables are limited to 4 TB.
| Profile | Use it for |
|---|---|
| Inference | Model request logs: timestamp, model ID, features, prediction, optional label; classification or regression |
| Time series | Any table with a timestamp column (e.g. aggregated signals) |
| Snapshot | Whole table profiled each run |
Inference profile setup: choose Problem type (classification or regression), the Prediction column, the Model ID column, and optionally the Label column (needed for quality metrics such as RMSE or R2). API: MonitorInferenceLog with problem_type, prediction_col, timestamp_col, model_id_col, granularities, label_col.
Outputs: a profile metrics table and a drift metrics table. The drift table has a drift_type (consecutive window or baseline). Baseline drift is only calculated if a baseline table is provided. For an inference profile, the best baseline is the training/validation data. Precision, recall, f1 are structs with per-class (one-vs-all) values for classification.
Alerts and custom metrics
- A Databricks SQL alert on a profile-table query runs on a schedule and emails by default: the low-code way to notify on R2 or drift.
- Custom metrics: aggregate (from primary table columns, stored in the profile table), derived (from aggregate metrics, profile table), drift (compares aggregate/derived metrics between windows or vs baseline, stored in the drift table). A weighted composite score = derived metric + drift metric on it.
Delta table history
DESCRIBE HISTORY table shows operation, user and timestamp for each write: use it to find when a column was dropped (default retention 30 days).
Exam traps
- Baseline ≠ a recent production batch; use training/validation data.
- Concept drift ≠ label drift ≠ feature drift: read what changes.
- Lowest-code monitoring = Inference profile + SQL Alert, not a workflow with a notebook.
- Overall accuracy can stay flat while per-class precision/recall (fraud class) degrades.
- Derived metric, not aggregate, when combining existing aggregate metrics.
- JS distance: no automatic cutoff.
- Streaming ML obstacles: out-of-order data and end-to-end fault tolerance.
Docs
- https://docs.databricks.com/gcp/en/data-governance/unity-catalog/data-quality-monitoring/data-profiling
- https://docs.databricks.com/gcp/en/data-governance/unity-catalog/data-quality-monitoring/data-profiling/monitor-output
- https://docs.databricks.com/gcp/en/data-governance/unity-catalog/data-quality-monitoring/data-profiling/monitor-alerts
- https://docs.databricks.com/gcp/en/data-governance/unity-catalog/data-quality-monitoring/data-profiling/custom-metrics
- https://docs.databricks.com/gcp/en/data-governance/unity-catalog/data-quality-monitoring/data-profiling/create-monitor-ui
- https://docs.databricks.com/gcp/en/tables/history