Data Drift Report
Operator: Abdulla Al Fahad. How tools are built and checked
A model trained on last spring's data keeps scoring this month's, and nothing in its output says whether the inputs still look the same. Drift checks answer that column by column: has the age profile shifted, did a new channel appear, has a field started arriving blank.
This page takes two tables with shared column names, a reference and a current one, and runs a different set of tests on number, date and category columns. It lists the tests that crossed their threshold beside the values, and exports a self-contained HTML report with charts for the columns that drifted.
Key features
- Numbers and dates: two-sample Kolmogorov-Smirnov test with its p-value, Population Stability Index over the reference deciles, and Wasserstein distance divided by the reference standard deviation
- Categories: chi-square test of homogeneity with rare categories pooled, Jensen-Shannon distance in base 2, and PSI
- Blank-share change per column, new categories with their share of rows, and categories that disappeared
- Editable thresholds, a rule for how many tests must flag a column, and a share of drifted columns that declares the whole dataset drifted
- Per-column histogram or bar chart of reference against current, a columns CSV, and an HTML report with no scripts
Which test runs on which column type and how a column is flagged
Columns are matched by header name, ignoring case and surrounding spaces. A column is a number when 90% of the reference values parse as numbers (currency symbols, percent signs and thousands separators are accepted), a date when they parse as dates, and otherwise a category. A category column in which more than half the values are different, and at least 50, is treated as an identifier or free text and skipped with the reason shown.
PSI sums, over bins, the difference between the current and reference share times the log of their ratio. The bins are the reference's deciles for numbers and the categories themselves for categories, and an empty share is replaced by 0.0001 so a category that appears or vanishes produces a large value instead of a division by zero. A common rule of thumb reads under 0.1 as stable and over 0.25 as a major shift; the default flag here is 0.2.
How it works
The KS p-value uses the Kolmogorov distribution with the usual small-sample correction. The chi-square p-value comes from the upper incomplete gamma function, and the implementation reproduces the textbook critical values (3.84 at one degree of freedom, 11.07 at five) for p = 0.05.
Wasserstein-1 is the area between the two empirical distribution functions, computed exactly over the merged values and divided by the reference standard deviation so columns in different units can share a threshold.
A column drifts when at least two of its three tests are flagged by default; you can change that to any one test or to all of them. Files over 100,000 rows are tested on a seeded random sample, which the page reports.
Common use cases
- A data scientist runs the check on the first of each month and keeps the HTML reports as a record of when the input mix changed.
- An analyst notices a model's approval rate has risen and finds that one channel went from 30% to 44% of rows.
- A data engineer after a schema migration compares the table before and after and sees a column's blank share go from 0% to 9%.
- A team lead comparing a training extract with a month of production data decides to retrain because 11 of 14 columns drift.
How to use this tool
- Drop the reference file and the current file, or load the built-in pair of invented loan tables.
- Adjust the thresholds if your monitoring uses different ones, and choose how many tests must flag a column.
- Choose Compare files. Progress is shown by column, and Cancel stops it.
- Open Show chart on a drifted column to see where the mass moved, then download the HTML report or the CSV.
Example
reference.csv and current.csv, 1,500 invented loan applications each (age, income, channel, region, credit_score, applied_on)
current: older applicants (mean age about 44 against 38), a new partner channel, income blank more often, applications dated six months later
region and credit_score are generated the same way in both filesResult with default thresholds
4 of 6 columns drift, so the dataset is flagged at the 50% default
age: KS 0.219 (p below 0.0001), PSI 0.280, Wasserstein 0.572, all three flag
channel: chi-square 128.1, Jensen-Shannon 0.189, PSI 0.298; new value partner on 3.3% of current rows
income: KS and Wasserstein flag (0.093 and 0.237), PSI 0.064 does not; blank share 1.7% to 7.8%
applied_on: KS 1.000, PSI 8.361 because the two files do not overlap in time
region and credit_score: no test flags them (region chi-square p 0.90, credit_score KS 0.027)Common pitfalls
With very many rows the KS and chi-square tests flag differences too small to matter. That is why the default rule asks for two tests, and why the page shows the size of each effect.
Tests on two samples show that distributions differ. They do not show that a model got worse, or why the data changed.
- Use the effect-size columns (PSI, Wasserstein, Jensen-Shannon) to rank columns, and the p-values only to ask whether a difference is more than noise.
- A date column that always drifts when the files cover different periods is expected; leave it out of the shared columns if you want to focus on the rest.
Common errors and how to fix them
- The two files share no column names, so there is nothing to compare.
- Rename the headers so they match; the comparison ignores case and surrounding spaces but needs the same words.
- Skipped: too few non-blank values to test.
- A column with fewer than five filled values in either file cannot be tested. Check that the column is not empty in one of the files.
- The file has more than 300,000 rows; only the first 300,000 are used.
- Sort or filter the file so the part you care about comes first, or split it, since the tests also sample down to the row limit you set.
Best practices
- Fix the reference file for a model's life and compare each new period against it, so a slow drift cannot hide by moving the baseline.
- Record the thresholds with the report, because a verdict is only meaningful together with the lines that produced it.
Why income flagged on two tests, not three
In the example the median income moved by only about 10% (from 39,900 to 44,095, and the mean from 44,120 to 49,210), and no single decile of the reference lost or gained much share, so PSI is 0.064, under the 0.2 line. The KS test and the Wasserstein distance both register the whole distribution sitting slightly higher, and 1,500 rows per file are enough for KS to call that significant. The default rule of two tests therefore flags the column, and the blank-share marker shows separately that values went missing, from 1.7% to 7.8%.
Frequently asked questions
Why not use a single test per column?
Each test has a blind spot: KS is sensitive near the middle and to sample size, PSI depends on the bins, and Wasserstein is dominated by the tails. Requiring agreement between two reduces false alarms, and the rule is one dropdown if you prefer any or all.
What happens to blank cells?
They are left out of the distribution tests and counted in the blank-share comparison instead, so a field that starts arriving empty is reported as such and not as a shifted distribution.
Does the HTML report load anything from the internet?
No. It is one file with inline styles and inline SVG charts, and no scripts, fonts or images are fetched when you open it. Every column name and category label inside it is escaped.