Cartoon robot detective examining laptop with magnifying glass and text about AI catching cheating models

Can AI Spot Data Leakage Before Your Model Hits 99% Accuracy?

The 97% vs 52% problem

The first case is a stock direction predictor built on Amazon price data. The task is simple to state: predict whether the closing price will finish above the opening price on the same day. The label is 1 when Close exceeds Open, and 0 otherwise.

Feed the model Open, High, Low, Volume, and same-day Close and Adj Close, and validation accuracy lands at 97.0% with an AUC of 0.999. Strip out the same-day close columns and keep only the prior day’s open, high, low, close, and volume, and accuracy collapses to 51.6% with an AUC of 0.476. That is a coin flip wearing a model’s clothes.

The leak is not subtle once you see it. The label is defined by comparing Close to Open. A feature set that includes Close hands the model the answer and asks it to perform one comparison. Every model tested flagged it immediately, and for the right reason. Sonnet’s phrasing was precise: the model “can reconstruct the label with a single comparison.”

Opus went further without being asked. Working from the feature list alone, it reasoned that “if High equals Open, the day never traded above the open, so the label must be 0,” and then predicted that a fair version of the model should land “in the low 50s for accuracy.” The clean run came in at 51.6%. The model called the honest result before anyone ran it.

Inside the experiment design

The setup matters as much as the findings. The authors planted classic leakage patterns in real datasets and, in each case, trained an actual model twice: once with the leak and once without, recording real numbers rather than hypothetical ones. The routes include a feature that mechanically defines the label, a feature built with future information, a split that ignores relational structure, and preprocessing performed in the wrong order.

On the review side, each pipeline was described in plain terms to four Claude models (Haiku 4.5, Sonnet 5, Opus 5, and Fable 5.1, as named in the source) and they were asked what they would flag before trusting the result. The controls were strict. Every model ran in a fresh, isolated session with no memory of the others. The description covered the pipeline, features, and code, with no ability to execute anything and, crucially, no hint that a leak existed. This is a closed-book exam, not a debugging session with a REPL.

The authors are explicit that this is not a cross-vendor comparison, and the write-up should be read that way. It is a probe of one model family against known ground truth.

Case 1: Stock direction prediction

The stock case is the cleanest demonstration because the leak is structural rather than statistical. Close and Adj Close do not merely correlate with the label; they participate in its definition. There is no modeling judgment to make and no threshold to tune. The feature set contains the label, and the model finds it.

What makes this case worth dwelling on is the gap between how obvious the leak is in hindsight and how plausible 97% accuracy looks in a results table. A practitioner skimming a report sees a strong validation score on a hard task and feels good about it. The number is not wrong. The evaluation is.

Case 2: Delivery duration prediction

The second case is harder and more instructive. The dataset is historical_data.csv, a subset of the Delivery Duration Prediction project: 197,428 orders, one row each, 16 columns. The target, duration_sec, is the actual delivery time minus the order creation time. Three columns (market_id, store_primary_category, and order_protocol) were excluded because encoding 74 restaurant categories had nothing to do with the leak under test.

The authors engineered one feature, store_avg, the average delivery duration for a store, and packed two separate leaks into it.

The first is target leakage. store_avg was computed by grouping the entire table, train and test rows together, by store_id and averaging duration_sec, which is the target itself, then copying that average onto every row. For stores with few orders, the average sits close to that row’s own duration, so the model reads a smoothed copy of the answer.

The second is temporal leakage. The created_at column makes the table inherently time-ordered, and shuffling before the standard 80/20 split lets training rows fall chronologically after test rows. A production model only ever sees earlier orders. The shuffled split lets it learn from the future, which is the one thing deployment will never permit.

Every model caught the store-average leak.

Quantifying the damage

The delivery case produces the number that should stick. With the leak, RMSE comes in at 862.7 seconds. Without it, 949.9 seconds. That is an apparent 9% improvement, and it comes entirely from the leak.

For scale: the average order in this dataset takes about 47 minutes to deliver, with a median of 44. An RMSE of 14 to 16 minutes means the honest model’s typical miss is close to a third of an average delivery. That is a mediocre model, and the leaked version is a mediocre model with a flattering score. A 9% gain is exactly the size of improvement that gets a feature promoted, a ticket closed, and a model shipped. It is also small enough to look like ordinary progress rather than a red flag.

This is the practical cost of leakage. It rarely announces itself with a suspiciously perfect score. More often it arrives as a modest, believable gain from a feature that seemed reasonable at the time.

What the models caught and how

Across the cases described, the models converged on a small set of reasoning patterns.

The first is label reconstruction. When a feature lets you compute the label with a single comparison, the model says so directly. This is what caught the stock case in every session.

The second is temporal ordering. The models treat created_at as a signal in itself: if the data has a time axis, the split has to respect it. Shuffling a time-ordered table is a leak waiting to happen, and the review flagged it as such.

The third is preprocessing order. Computing an aggregate over the full table before splitting is a different operation from computing it over the training fold alone, and the models distinguished the two. The order of operations, not just the choice of feature, determines whether information crosses the train/test boundary.

What the models did not do is reason about which split strategy a given relational structure demands. That judgment, deciding whether a group split, a time-based split, or a plain random split is appropriate for the data at hand, remains a human task. The models flag the symptom. The engineer diagnoses the cause. The same division of labor shows up in reproducibility work, where turning a reproduction into a reusable artifact still requires someone to decide what the original authors probably meant when the paper and code disagree.

The limits of the test

Three caveats deserve equal billing with the results.

First, this is not a cross-vendor comparison. Four models from one family were tested. The findings say something about Claude’s leakage detection, not about LLMs in general.

Second, the closed-book setup is both the experiment’s strength and its ceiling. Isolating each session and withholding any hint of a leak makes the test fair. It also means the models could only reason from the description provided. A pipeline described incompletely would produce a different result, and the study cannot tell you how sensitive the detection is to how the pipeline is written up.

Third, the source write-up does not report the full model-by-model results for every leakage route it set up. Any claim about how the models handled those routes would be speculation.

A practical leakage checklist for engineers

The experiment distills into four checks worth running before any metric is trusted.

Feature provenance

For every feature, ask whether it could have been computed without the target. If the answer is no, or if computing it required the target column to be present in the same table, treat it as suspect. The stock case fails this check instantly.

Split strategy

Match the split to the data’s structure. Time-ordered data needs a time-based split. Grouped data needs a group split. A random shuffle is a default, not a decision, and it is the wrong default more often than most pipelines assume.

Preprocessing order

Fit every transform on the training fold only. Aggregates, scalers, encoders, and imputers all leak when computed over the full table before splitting. The delivery case shows how a single groupby over the whole dataset can smuggle the target into a feature.

Suspiciously high accuracy

A score that beats the domain’s known ceiling deserves a manual audit, not a celebration. The stock model’s 97% is the kind of result that should trigger a review, and that review would have taken minutes.

The broader lesson is about where AI review fits. The models in this experiment caught the leaks they were shown, and Opus predicted the clean baseline before it was run. That is a genuinely useful first pass, cheap enough to run on every pipeline description. It is not a substitute for an engineer who understands why the split matters. Used as a pre-flight check, it catches the leaks that are structural and obvious in hindsight. The rest still need a human who knows the data. As AI credentials proliferate and certifications compete for attention, the skill this experiment rewards is unglamorous and durable: reading a pipeline closely enough to notice that the answer is sitting in the feature list.

Similar Posts