Model validation

Data leakage in insurance models: the future is the easiest feature to use by accident

A datum is admissible only if it was observable at the exact moment the decision would have been taken. Everything else is the future, and insurance files, corrected and completed long after the events, are full of it. A model that uses it looks excellent in testing and disappoints in production.

One rule: observable at the moment of the decision

The question to ask of every field is not whether it is in the file today, but whether it could have been read at the exact moment the model will be used: when the policy is priced, when the claim is reported, when the reserve is set. If not, it is the future, and the future is the easiest feature to use by accident, because it sits in the same table as the past and predicts the outcome remarkably well.

The future gets in two ways. Directly, when a variable is partly a consequence of the outcome. And by contamination, when the same customers, policies or claims, or a preprocessing step fitted on all the data, sit on both sides of the split.

Where the future hides in insurance files

Claim counts and costs that keep developing after the period being modelled. Fields filled in during claim handling, such as the number of contacts, an expert appointment or a fraud flag, used to predict the claim itself. Statuses corrected after the fact, case reserves revised later, closures recorded late. Tables that keep only the current address or vehicle. And encodings, groupings, imputations and scalings computed on the whole dataset before it is split.

Why a random split hides it

Policies of the same year share their calendar: inflation, changes in claims handling, a new provider network, a regulation. A random split of the same years puts that calendar, and the future, on both sides, so the leaked variable looks like a strong, genuine predictor. Tested on a later period, where the information did not yet exist, its contribution vanishes. Only a test on later data measures the forecast the model will be used for.

The rule built into our tools

Our imputation tool works “as of” a valuation date: every column declares when its value becomes known, and at that date a value not yet known is treated as missing, even though it is in the file today. A claim with an accident on 1 January, a diagnosis recorded on 5 January and a payment on 20 January, valued on 10 January, can use the diagnosis, not the payment. When the valuation date is the training cutoff, the default, nothing recorded after it fills the past, neither as a value nor as a learned parameter; the one limit that remains is stated in our article on imputation.

The same rule governs our backtests. At a past date, a claim counts as closed only if the closure rule in force would already have closed it, and claims are never cut at a fraction of their final length, a length known only once they close. The validation of our trajectory model keeps each insured whole on one side of the split, and our imputation and risk-grouping steps learn their parameters on the training part only.

Testing at past dates

A test on later data is honest only if, at the cut date, the model sees what was known that day and nothing else. Three of our engines are built that way.

Our trajectory model for reserving is backtested at a past cut date: it sees only the events dated and reported by then, chained into episodes with what was known that day, and it is judged on what came after. A claim that occurred before the cut but was reported later is counted apart, for its own reserve, never as part of the trajectory the model had to foresee.

Our estimate of the number of claims incurred but not yet reported is backtested at several past dates: at each one, the reporting triangle is rebuilt with the claims reported by then, the estimate is made, and it is compared with the claims that had occurred by that date and were reported afterwards. One line per date shows whether the method is right at one date only or at all of them; Tashman (2000) describes this rolling-origin design for forecasting.

When a date is declared, our risk-grouping step chooses its number of groups on time-ordered folds: it learns on the earlier periods, validates on the next one, and removes from the learning rows every unit, a policy or an insured, that also appears in the validation block. Our pricing-model fit can likewise keep a later period as its test set, but only when the analyst declares one: by default, it does not split on dates.

What it caught in our own work

To choose how much memory our trajectory model needs, a split by claim chain rather than by insured let the model recognise insureds it had already seen: on a simulated portfolio, it showed an error of 1.20 and chose two steps of memory; split by insured, the honest error was 3.62 and the useful memory zero. Our article on the trajectory model tells the rest.

Choosing the training claims by what happened later is the same mistake in another form. Auditing our own reserving engine, we found that a claim-level model trained only on closed claims learns from claims that are, on average, shorter, because claims that continue are more often still open; learning also from the steps of open claims whose outcome is already known removes most of that bias. Our article on backtesting explains how a backtest rebuilt as of past dates makes it visible.

Checking a model someone else built

Write down, for every variable, the date at which it becomes known, and compare it with the decision date. Compare a random split with an out-of-time split: a large gap is a warning. Be suspicious of a single variable that dominates the importance ranking, or of a score too good for the problem. Adversarial validation, a classifier trained to tell the training period from the test period, points to variables whose meaning changed over time.

References

S. Kaufman, S. Rosset, C. Perlich and O. Stitelman (2012), “Leakage in data mining: formulation, detection, and avoidance”, ACM Transactions on Knowledge Discovery from Data; L. J. Tashman (2000), “Out-of-sample tests of forecasting accuracy: an analysis and review”, International Journal of Forecasting; T. Hastie, R. Tibshirani and J. Friedman (2009), The Elements of Statistical Learning, 2nd ed., Springer, section 7.10.2.

Raphael Sebbah

About the author

Raphael Sebbah

Actuary (ISUP) and data scientist, founder of Smart Data Science. Formerly at Amundi (CAAM), Dexia, AIG and Phoenix; co-author of research published in The European Physical Journal C and Brain Communications.

LinkedIn · ORCID · Google Scholar

More publications

Publications
Statistics

Correlations: deciding which relations deserve to be read

A correlation matrix can give hundreds of mathematically correct numbers and several false conclusions. Computing a correlation is not our problem; deciding which test to read, and whether the relation deserves to be read at all, is. This article follows our correlation and test engines step by step, in the order they run, with the rules that decide and the measurements that show where the usual shortcuts go wrong: what one observation is, which quantity is compared and which test it calls for, which assumptions are checked and on what, what time, controls and segments change, how many tests were really run, and what the engines refuse to compute rather than guess.

Read the article
Statistics

The statistical paradoxes we check for, function by function

A result can be computed without a single error and still say the opposite of the truth. Simpson’s reversal, the winner’s curse, Galton’s problem, multiplicity, Jensen’s inequality and censoring: for each, a defect we found in our own code and how it was shown; where the fix is done, its formula and the measurement after it; where not, the register entry that tracks it. The review goes function by function and is not finished.

Read the article
Causal inference

Did it work? Measuring the effect of a decision without fooling yourself

A campaign, a new deductible, a reminder letter: did it change the outcome? Comparing those who received it with those who did not answers a different question. This article shows how we estimate the effect of a decision on observational data, what each estimate assumes, why the usual estimator can fail when the decision is rolled out in waves, what we do when only a few units received it, and how we keep a study of many segments from finding effects that do not exist.

Read the article

Let’s build better decisions together

Tell us about the decision you need to make.

A few lines are enough: your sector, the data you have and what you want to improve. We reply personally with a first view of the approach.

  • A few lines are enough
  • NDA on request
  • Code and documentation handed over