Data Quality and Lineage for Models: Checks, Drift and Defects
Many model failures that reach production begin as data problems. A column changed units, a feed dropped a field, a join quietly duplicated rows. The model still ran, the metrics looked plausible, and the decisions got worse. This article sets out the dimensions of data quality, the checks worth running before you model, how to separate a data defect from genuine drift, and what to document. It finishes with a worked example on synthetic data.
Dimensions of data quality
Different frameworks use slightly different names. These six are widely used and enough for most teams:
- Completeness. Are required values present, and is missingness random or concentrated in a segment?
- Validity. Do values fall in allowed ranges, formats and code lists? An age of 150 is invalid.
- Uniqueness. Is each real-world entity or event recorded once?
- Consistency. Do the same facts agree across fields and systems, and are codes spelled the same way?
- Accuracy. Do values match reality? This is the hardest to test, usually by reconciliation to a trusted source.
- Timeliness. Is the data fresh enough, and was it available at decision time?
Referential integrity (every loan points at a customer that exists) is often treated as part of consistency; it deserves its own check.
Checks that matter before modelling
Run these on every new extract, and automate them:
- Row counts and key uniqueness, by period and source, against expectations.
- Missingness by column, by period and by segment. A rise concentrated in one channel is a feed problem.
- Range and unit checks: minimum, maximum, and share outside plausible bounds; medians by source and period.
- Code lists: every categorical value on the approved list, with consistent case and spelling.
- Referential integrity: foreign keys exist in the master table.
- Reconciliation: total balances, counts and defaults tie to the ledger or reported figures within tolerance.
- Point-in-time correctness: each feature is built from information available at the decision date, to avoid leakage.
A check is only useful if it has a threshold, an owner and a rule for what happens on failure (stop, quarantine, or warn).
Data defects versus data drift
Both show up as a distribution change, but they call for opposite responses.
- A defect is the data being wrong: a unit change, a dropped field, a duplicated join. The fix is upstream, and the affected rows should not be scored or trained on until repaired.
- Drift is the data being right but different: customers really are earning more, or a new segment is arriving. The response is analysis, recalibration or redevelopment.
Clues: defects are abrupt, usually confined to one source, channel or load date, and often produce impossible values. Drift tends to be gradual, broad and plausible. Always slice by source and load date before concluding anything. The Population Stability Index (PSI) compares a variable’s distribution in a reference and a current period:
PSI = sum over bins of (current% - reference%) x ln(current% / reference%)
A common convention treats 0.10 as a reason to look and 0.25 as a material shift; these are rules of thumb, not laws. PSI tells you that something changed, not why. See monitoring models in production for how to use it over time.
Figure 1. Where each kind of check sits along the data lineage. Illustration.
Illustrative example with synthetic data
We built 20,000 loan records over 12 months from three channels (branch, online, broker), then planted problems of the kind seen in real feeds, plus 160 duplicate rows, giving 20,160 rows.
Static checks. Failure rates across the whole file:
| Check | Rows failing | Share |
|---|---|---|
| Income missing (completeness) | 1,306 | 6.48% |
| Non-standard status code (consistency) | 300 | 1.49% |
| Customer id not in master (integrity) | 250 | 1.24% |
| Duplicate loan id (uniqueness) | 160 | 0.79% |
| Age outside 18 to 100 (validity) | 45 | 0.22% |
| Negative balance (validity) | 30 | 0.15% |
Reconciliation catches the duplicates in money terms: total balance is 253,265,568 including duplicates and 251,385,605 without, so the model file overstates exposure by 0.75%.
Figure 2. Share of rows failing each check. Synthetic data.
Slicing finds the real problems. The 6.48% missing income hides a pattern. Among broker loans, missing income is between 0.3% and 1.9% in each of months 1 to 6, then 54.2% to 61.3% from month 7. Online loans stay between 0.6% and 1.7% throughout. That is a broker feed change, not random missingness, and imputing the average income would hide it.
Units. Median branch income is between about 39,000 and 41,000 in months 1 to 8 and then 40 to 41 from month 9: 2,722 branch rows have an income below 1,000, and every one is in month 9 or later. Someone changed the branch feed to thousands. The all-channel income PSI jumps from about 0.01 in month 8 to 0.937 in month 9; for branch alone it exceeds 8, a figure set largely by how empty bins are floored in the calculation; the point is that the two distributions no longer overlap.
Genuine drift looks different. We planted a rise in online incomes of 1.2% a month. Online median income rises from 42,543 in month 1 to 46,895 in month 12. Its PSI against months 1 to 3 climbs gradually, with some noise, and reaches 0.062 by month 12, still under the 0.10 level. That is real movement worth watching, not a bug to fix.
Figure 3. Monthly income PSI for branch (a defect) and online (gradual drift). Synthetic data.
A model trained on months 1 to 8 and scored on month 9 branch loans would see incomes about a thousandth of normal. The failure is in the data, and no amount of model tuning repairs it.
Documentation
Record, in a form someone else can use:
- a data dictionary: field meaning, unit, allowed values, source system and refresh cadence;
- lineage: each model field traced from source through every transformation, join and filter, to the model input;
- a known issues log: defects found, date, affected population and treatment (excluded, corrected, imputed);
- the checks run, their thresholds and results for the development and each production run;
- change history: who changed a feed or transformation and when, so a break in a series can be traced.
This is what lets a validator or a successor reproduce your dataset, and it is the first place to look when performance changes.
What goes wrong
- Checking totals but not slices, so a segment’s failure disappears into a clean average.
- Imputing or filtering silently, with no record of what was removed.
- Treating every PSI alert as drift, or every distribution change as a defect.
- Learning of a feed change from model performance months later.
- Features built from fields that were not available at decision time.
- Checks with no threshold, no owner or no consequence.
- Documentation written once at development and never updated.
How to start
- Pick your most important model and list its twenty most influential inputs and their sources.
- Automate the seven pre-modelling checks for those inputs, by source and load date.
- Add a monthly report that shows missingness, median and PSI by source, with a named owner.
- Start a known issues log and a data dictionary. A shared spreadsheet beats nothing.
An illustrative project
A hypothetical lender’s default model loses performance one quarter. Rather than retrain, the team slices input distributions by source and load date. It finds a broker feed that stopped sending income and a branch feed that switched units, agrees fixes with the data owners, and quarantines the affected months. It then adds source-level checks to the monthly pack and records both incidents in the issues log. This is an anonymised, synthetic scenario, not client work.