Library · Credit scoring

Concept drift and data drift

A model can stop working in two ways. The population it scores changes, which is data drift. Or the relation between inputs and outcome changes, which is concept drift. Monitoring the inputs detects the first and is blind to the second.

By , published

Definition

Write x for the inputs and y for the outcome. Data drift, also called covariate shift, is a change in the distribution of x with an unchanged relation between x and y. Concept drift is a change in that relation, whatever happens to x. Gama and co-authors review the forms it takes: sudden, gradual, recurring.

The distinction matters because the two are monitored with different data. Data drift is visible at once, from the inputs alone. Concept drift is visible only when outcomes arrive, which for a twelve-month default takes a year.

Worked example

A scoring model is developed on one period. In scenario 1 the new applicants are riskier but behave as before. In scenario 2 the applicants are the same, and the second variable stops predicting default. We compute the PSI of the score and the AUC in each scenario.

import numpy as np
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import roc_auc_score

rng = np.random.default_rng(27)
def population(n, shift=0.0, w2=1.0):
    X = rng.normal(size=(n, 2)) + [shift, 0.0]
    y = (rng.random(n) < 1 / (1 + np.exp(2.5 - 1.0 * X[:, 0] - w2 * X[:, 1]))).astype(int)
    return X, y

def psi(e, a, bands=10):
    edges = np.quantile(e, np.linspace(0, 1, bands + 1))[1:-1]
    pe = np.bincount(np.searchsorted(edges, e), minlength=bands) / len(e)
    pa = np.clip(np.bincount(np.searchsorted(edges, a), minlength=bands) / len(a), 1e-4, None)
    return np.sum((pa - pe) * np.log(pa / pe))

X0, y0 = population(50_000)
model = LogisticRegression().fit(X0, y0)
s0 = model.predict_proba(X0)[:, 1]
print(f"development:                    AUC = {roc_auc_score(y0, s0):.3f}   default rate = {y0.mean():.3f}")
for name, kw in [("1. data drift (riskier applicants)", dict(shift=0.8)), ("2. concept drift (x2 stops working)", dict(w2=0.0))]:
    X, y = population(50_000, **kw)
    s = model.predict_proba(X)[:, 1]
    print(f"{name:36s} PSI = {psi(s0, s):.3f}   AUC = {roc_auc_score(y, s):.3f}   predicted {s.mean():.3f} vs observed {y.mean():.3f}")

Output, produced by running the code above when this page was built:

development:                    AUC = 0.812   default rate = 0.131
1. data drift (riskier applicants)   PSI = 0.299   AUC = 0.811   predicted 0.220 vs observed 0.220
2. concept drift (x2 stops working)  PSI = 0.000   AUC = 0.681   predicted 0.131 vs observed 0.108

In the first scenario the PSI is far above any threshold and the model still ranks and predicts correctly. In the second the PSI is near zero, and the model has lost much of its ranking power and predicts the wrong default rate.

Where it misleads

  • An alert on the inputs is not a verdict on the model. A model can remain accurate on a shifted population if the relation it learned still holds there, as in the first scenario.
  • Stable inputs are not a clean bill of health. The second scenario is the dangerous one, and no input monitor can see it.
  • Outcome-based monitoring is late by the length of the outcome window. Early indicators, such as first missed payments, shorten the delay at the price of a different target.
  • A drop in AUC can come from the population alone: a narrower population lowers it with no change in behaviour.

A model monitoring plan therefore has both: the population stability index on inputs and score, and discrimination and calibration on outcomes as they mature.

In our work

The stability section of our credit validation report shows both sides: the PSI of the score, and what it does not see. The monitoring we set up tracks inputs and realised outcomes separately.

References

  1. Gama, J., Žliobaitė, I., Bifet, A., Pechenizkiy, M., Bouchachia, A. (2014). A survey on concept drift adaptation. ACM Computing Surveys, 46(4), 1-37. doi:10.1145/2523813
  2. Moreno-Torres, J. G., Raeder, T., Alaiz-Rodríguez, R., Chawla, N. V., Herrera, F. (2012). A unifying view on dataset shift in classification. Pattern Recognition, 45(1), 521-530. doi:10.1016/j.patcog.2011.06.019
  3. Yurdakul, B., Naranjo, J. (2020). Statistical properties of the population stability index. Journal of Risk Model Validation, 14(4), 89-100. doi:10.21314/JRMV.2020.227

Have a question like this one on your own data? Tell us what you need in a few lines.

Send us the brief

Related pages

  • PSI: the population stability indexThe population stability index sums, over score bands, the difference between two shares times the log of their ratio. The usual thresholds of 0.10 and 0.25 are conventions: with small samples or many bands, PSI exceeds them when nothing has changed.
  • Probability calibration: slope and interceptCalibration asks whether predicted probabilities match observed frequencies. Two numbers summarise it: the intercept, for the overall level, and the slope, for the spread. A slope below 1 means predictions that are too extreme.
  • Reject inferenceLenders observe repayment only for the applicants they accepted. Reject inference tries to correct the selection bias of a model built on that sample. Whether a correction is needed, and possible, depends on how the past decisions were taken.
All library pages