ML Systems Lab Open interactive version →
Intermediate 29 min read data qualityschema driftvalidationGreat Expectations

Data Quality for ML

Schema drift, distribution shift in features, null rates, automated validation

It is 3am. An alert fires: the fraud model has stopped returning high-confidence positives. Nothing was deployed in the last two days. The model? Running fine. The feature pipeline? Reported success. The upstream transaction table? Zero rows for the last two hours — an ingestion outage upstream. No error was ever thrown. The pipeline happily ran on empty windows, produced all-zero feature vectors, and the model scored every transaction as low-risk. Thousands of fraudulent orders sailed through unflagged.


The one asymmetry that makes data quality hard: bad data doesn't raise exceptions

An empty table returns in 5 milliseconds. A feature that nulls out because a join failed hands you a number, not an error. A model fed all zeros returns a confident score. At every layer the system reports *success* while quietly producing garbage. That is why "did the pipeline run?" tells you almost nothing — you have to actively *check the data itself.*


So you check it at every stage

At *ingestion:* does the data even exist, in the expected volume, with the expected schema? At *feature computation:* are null rates in bounds, are distributions close to training? At *training:* does the label rate match history, has any feature's mean drifted more than 2σ? At *serving:* does the live feature schema still match training, are values in range?


The five checks that catch the most

*Freshness* — is data arriving on time (alert when nothing new for longer than expected). *Completeness* — null rates within bounds, per feature. *Validity* — values in range, categories from the known set. *Volume* — row count within ±30% of the rolling weekly average. *Schema consistency* — no surprise column renames or type changes from upstream. Tools like Great Expectations and TensorFlow Data Validation turn these into assertions that *fail the pipeline loudly* — not dashboards someone has to remember to open.

And the mindset that ties it together: data quality is never "done at launch." Upstream teams change schemas, inject nulls, and shift distributions all the time, and they will not tell you. The real question isn't "is our data clean today?" — it's "will our monitoring catch the problem before the model does?" A pipeline that screams on day one of a schema change beats one that silently retrains on corrupted features for six weeks.

Key points

Takeaway

Bad data throws no exceptions — the only thing that distinguishes "pipeline ran" from "pipeline ran on data the model was trained to handle" is data quality assertions you wrote before the incident happened.

Recap

Check your understanding

Q1. Your training pipeline runs successfully every day, but model performance has been slowly degrading over 3 weeks with no code changes. Select the two correct diagnostic steps.

Q2. You add a new upstream data source to your feature pipeline. How do you validate data quality before using it in training?

Q3. A feature pipeline runs successfully but produces the wrong values — all "user_account_age" values are approximately 365 days regardless of actual account age. How does data validation catch this?

Q4. How do you implement data quality checks that catch issues before they affect model training, without slowing down the pipeline significantly?

Try it interactively

ML Systems Lab is a free interview-prep platform for ML engineers — work through the full interactive module, quizzes, and drills.

Open ML Systems Lab →