A football model can post a flattering score for the wrong reason: the preprocessing saw the rows it was later tested on. Nothing crashes. The number simply lies. This tutorial treats that failure as an engineering task. You will declare what the feature table promises, see where a scaler or feature selector quietly peeks at test rows, and fix it with a split-first habit and a pipeline. The examples assume a small synthetic fixture table, labelled as synthetic and never real match history. No score below is a measured result of this site's own code.
Declare the feature table before touching a scaler
Start with a contract, not a model. A synthetic fixture might hold one row per fixture with a kickoff timestamp, a rolling goals-per-match average in goals, a rest-days count in days, and a result label. For each column, write down when it becomes available. A rolling average computed after the final whistle is not a pre-match feature, and no scaler can repair that. This is the plain definition of leakage: information that would not exist at prediction time.
The contrast is useful. A column known the evening before kickoff belongs in the table. A column that summarises the match itself does not, even when it correlates beautifully with the label. Writing the availability time next to every column turns a vague worry into a checkable rule, and it gives you something concrete to reject malformed rows against later.
How the leaky version inflates a score
Here is the classic mistake. Take all rows, run feature selection on the full table, then split into training and test sets. The selector has already seen the test labels, so it keeps whichever features happen to line up with them. The scikit-learn documentation demonstrates this with randomly generated targets, where the expected accuracy is near chance, yet selecting on all the data produced an accuracy far above chance.

Imagine a hypothetical fixture table with hundreds of noisy columns and a coin-flip label. A leaky pipeline would still report an impressive result, and the temptation is to believe it. The same rule covers every learned step. Dividing by an average that includes test rows lets the test subset influence the model, which is why the documented general rule is never to call fit on test data.
Split first, then fit on training rows only
The corrected order is short. Split the table, call fit or fit_transform on the training subset, and call only transform on the test subset. The transformation learned from training must then be applied to later data too. In the documented scaling example, the training set was scaled but the test set was not, and the test error came out far worse than expected, because the feature space the model saw had changed.
Two mistakes, then, mirror each other. Fitting on everything leaks test information into the model. Skipping the transform on test rows breaks the feature space. Both vanish under one discipline: learn from training rows, apply everywhere. The same holds in production, where each new fixture row must pass through the exact transform learned during training.
Let a pipeline enforce the order
Discipline fails at 2 a.m. A pipeline makes the correct order the only available order. Chaining a scaler, a selector and an estimator means a single fit call learns each step from the training rows only, and a single predict call applies each step in sequence. The documentation notes that pipelines reduce the chance of forgetting a transformation and also help prevent leaking test data into training.
Cross-validation raises the stakes. If you score a model across folds after fitting a scaler once on the full table, the leak repeats in every fold, so the scaler belongs inside the pipeline where it is refitted on each training split. For a sense of what a plain cross-validation report looks like, the documentation scores a linear support vector classifier on the iris data over 5 folds and gets a mean accuracy of 0.98 with a standard deviation of 0.02. That example involves no preprocessing at all. Its separate train-test illustration does fit its scaler on the training split only, and that is the habit to copy. Neither is a football benchmark.
Run a falsifiable check before trusting any score
The following checks are editorial recommendations for the synthetic fixture, not behaviour documented in the cited excerpts. First, a bad-input test: a row with a missing label, or two rows sharing one kickoff timestamp for the same team, should be rejected with a clear error rather than silently averaged. An empty table should fail loudly too. Second, a shuffled-label test: shuffle the labels so features and targets are independent, then evaluate. A sound pipeline should land near chance, and a high score on shuffled labels strongly suggests a leak worth investigating.
Remember why the held-out split exists at all. Learning parameters and testing on the same data is a methodological mistake that leads to overfitting and an overly optimistic score. Tweaking settings until the test number improves leaks knowledge the same way. Chronology adds a rule these excerpts do not cover: for football, order rows by kickoff time and train only on earlier matches, then confirm the timestamps are sorted before splitting.
Treat the evaluation order as part of the model. A score is only worth reading when every learned step, scaling and selection included, saw training rows alone, and when a shuffled-label run drops to chance. Wrap the steps in a pipeline, reject malformed rows before fitting, and keep fit, evaluation and deployment as separate stages with separate data. Sample size, calibration and chronological validation deserve their own tests. None of this promises a profitable model. It only keeps the number honest.
Sources consulted
- 12. Common pitfalls and recommended practices — scikit-learn 1.9.1 documentation
- 3.1. Cross-validation: evaluating estimator performance — scikit-learn 1.9.1 documentation
18+ only. Models do not guarantee results. See our Responsible Gambling page.
