Field notes. Opinions marked as opinions.

A model that predicts loan defaults with 97% accuracy should make you suspicious, not happy. Real credit behaviour is messy. If a first attempt looks that clean, I assume leakage until proven otherwise. That is opinion, but it has a good hit rate.

What leakage is

Leakage means the model was given information at training time that it will not have when it is actually used. The model is not cheating on purpose. It simply finds the strongest signal in the data, and if that signal is a consequence of the outcome rather than a cause, it will happily use it.

The test is one question. At the moment of prediction, would this value already exist? If the answer is no, or “only sometimes”, the column is a leak.

Three ways it gets in

The column that is really the answer in disguise. You are predicting which loan accounts will default. The table has a field called “recovery agent assigned”. It is filled in only after an account goes bad. The model learns that this field predicts default almost perfectly. In production, at the time you need the prediction, the field is empty for everyone. Similar examples: “refund processed” in a model predicting refunds, “discharge summary written” in a hospital readmission model, “exit interview done” in an attrition model.

Timing leaks are the dull cousin. A feature such as “number of support tickets in the last 90 days” is fine if you calculate it as of the prediction date. If you calculated it as of today for every historical row, the customers who churned in March have tickets from April, May and June in their count. Those tickets were caused by the churn process. Always compute features as they stood on the prediction date, a practice usually called point-in-time correctness.

Preparation done before the split. You scale the data, fill missing values with the column average, or pick the “best 20 features” using the full dataset, and only then split into training and test. The test rows have already influenced the rules by which everything was prepared. The damage is usually smaller than with the first kind of leak, but it inflates scores and it is easy to avoid: split first, learn every transformation from the training part only, then apply it unchanged to the test part.

Duplicates and relatives across the split. The same customer, the same invoice entered twice, or near-identical rows land on both sides. The model recognises them. Your test score then measures memory. Split by customer or by account when one entity has many rows.

A short case, with made-up numbers

A lender builds a default model on 40,000 past loans. First run: 96% accuracy and a happy review meeting. Someone asks which features matter most. Top of the list is “number of collection calls made”. That count is zero for good borrowers and rises for troubled ones. Collection calls begin after the first missed payment. The model had learned to read the consequence.

The team removes the field and anything else created after the loan was sanctioned, and rebuilds with only application-time data such as income, existing obligations, bureau score at application and loan size. Accuracy drops to the low eighties. The number is worse, and for the first time it is true. Note also that raw accuracy is a poor yardstick when defaults are rare, so they should look at precision and recall as well, but that is a separate subject.

How to catch it before production does

  • Distrust results that are too good. Compare against a dull baseline such as “predict the most common outcome” or last period’s value. If you beat it by an absurd margin, investigate.
  • Read the feature importance list like a detective. Any top feature you cannot explain as a cause or early sign gets a sit-down with whoever owns the source system.
  • Ask the data owner when each column gets populated. Operations people usually know in thirty seconds what the data team spent a week guessing at.
  • Validate over time. Train on older periods, test on a later period. Leaks that depend on the future tend to collapse here.
  • Watch for a sharp gap between test performance and the first weeks of live performance. That gap is the leak showing itself, expensively.

Where the idea stretches beyond models

Leakage is not only a machine learning problem. A dashboard that says “customers who bought the premium plan have higher retention” may be reading the same reversed arrow: customers who stuck around long enough got offered the premium plan. The retention came first. Any time an analysis uses a fact that is only knowable after the thing being explained, the same question applies.

One more opinion. Teams spend a lot of energy choosing between algorithms and very little on this. A plain logistic regression on honest features beats a gradient-boosted monster on leaky ones every time it counts, which is the day the model goes live. Spend your review time on the columns.

Figures and names in the examples are illustrative.

Leave a Reply

Trending