الانتقال إلى المحتوى
Machine Learningتقييم الموديلات· 7 دقائق للقراءة

A 0.5% Better Score Might Be Noise: Comparing Models Properly

One split is one draw. Compare candidates on the same repeated splits, correct for overlapping folds, and a small win often turns into a tie.

ReadIn

مقال كل يوم يفرق معاك

22 نوفمبر 2026
  • كاتب موثّق
محتويات المقال

A pull request replaces the team's logistic regression with an SVM. The description reads "test accuracy 0.965 → 0.972" and the reviewers approve: the test set was held out, the numbers are real, and higher is better. Nobody notices that the test set has 143 rows, so the whole improvement is one tumor sample classified differently. Split the same data 30 different ways and the SVM wins 5 times, ties 6 times and loses 19.

The common misconception

Many developers read a higher score on the held-out split as a verdict: model B scored more than model A, so B is the better model. It's an easy belief to hold:

  • The test set was never used for training, so the number feels clean and final.
  • Leaderboards and benchmark tables rank models by a single score, often to the second decimal.
  • Scores print with three or four decimals, which looks like precision.

The half-truth: each score is a genuine measurement of that model on those rows. But it's a measurement on one sample of rows. Draw a different sample and the scores move, sometimes enough to swap the ranking, and you can't read a gap until you know how much the scores move on their own.

What actually happens

Evaluating two models means estimating the difference between them, and every estimate comes with noise. The work is in measuring that noise honestly.

A test score is one draw

Which rows end up in the test set is chance. On 143 rows, each row is worth 0.7 points of accuracy, so a gain of 0.5 points can't even be observed. For a model near 97% accuracy, the binomial standard error on 143 rows is about 1.4 points, twice the gap in the pull request. A single split can't tell a better model from a luckier split.

Compare on the same splits, in pairs

Some splits are easy for every model and some are hard. scikit-learn's guide to comparing models points out that models evaluated on the same partitions have correlated scores for exactly that reason. So don't compare two averages with their own error bars: compute the difference between the models on each split, using identical splits for both. The shared luck cancels out, and what's left is the difference you care about.

Folds overlap, so correct the variance

Repeated K-fold gives you many paired differences, but they aren't independent. With 5 folds, any two training sets from the same repetition share three quarters of their rows. A plain t-test treats the differences as independent, underestimates their variance and finds differences that aren't there. In scikit-learn's example, an uncorrected test gives a of 0.005 for a gap that the corrected test puts at 0.227. The correction comes from Nadeau and Bengio, whose work on the variance of cross-validation estimates accounts for the choice of training set: multiply the variance by 1/k + n_test/n_train instead of 1/k, where k is the number of scores. The second term never shrinks, so more repeats can't manufacture significance.

Python
from sklearn.datasets import load_breast_cancerfrom sklearn.linear_model import LogisticRegressionfrom sklearn.model_selection import train_test_splitfrom sklearn.pipeline import make_pipelinefrom sklearn.preprocessing import StandardScalerfrom sklearn.svm import SVCX, y = load_breast_cancer(return_X_y=True)model_a = make_pipeline(StandardScaler(), LogisticRegression())  # currentmodel_b = make_pipeline(StandardScaler(), SVC())  # candidateX_tr, X_te, y_tr, y_te = train_test_split(X, y, stratify=y, random_state=19)acc_a = model_a.fit(X_tr, y_tr).score(X_te, y_te)acc_b = model_b.fit(X_tr, y_tr).score(X_te, y_te)print(f"A {acc_a:.3f}, B {acc_b:.3f}, gap {acc_b - acc_a:+.3f}")print(f"one test row is worth {1 / len(y_te):.3f}")# A 0.965, B 0.972, gap +0.007# one test row is worth 0.007

On the team's split, B wins by 0.007: one row out of 143, the entire improvement. Over 50 paired splits, B is 0.33 points worse on average and wins 13 times. The corrected 95% runs from −1.67 to +1.00 points, with p = 0.62. With these 569 rows, a real gain of up to 1 point and a real loss of up to 1.7 points are both consistent with the data. Without the correction, the interval would be about 3.7 times narrower and would look far more decisive than it is.

The honest verdict isn't "A is better" either. It's a tie at this data size, and a tie is decided on other grounds: A is already in production, simpler to explain and cheaper to run.

The seed is noise too

The split isn't the only roll of the dice. Bouthillier and colleagues found that variance from data sampling, parameter initialization and hyperparameter choice markedly changes benchmark results. scikit-learn's guide to controlling randomness warns that a model that looks good under cross-validation with one fixed seed may just have been lucky with that seed. It recommends letting the estimator's randomness vary across folds, while giving the CV splitter an integer random_state so every candidate sees the same folds.

MythReality
B scored higher on the test set, so B is betterThe 0.7-point win was one row; across 30 splits B won only 5 times
Three decimals mean a precise scoreOne row moves accuracy by 0.007; the standard error is about 0.014
A t-test on fold scores settles itFolds overlap; uncorrected, scikit-learn's example gives p = 0.005 instead of 0.227
Enough CV repeats make any gap significantThe corrected variance keeps an overlap term that never shrinks
No significant difference means the models are equalIt means the data can't tell; the interval shows what could still hide

How to apply it in your project

  1. Fix one set of splitsUse RepeatedStratifiedKFold with an integer random_state, shared by every model you compare.
  2. Record differences, not two averagesScore both models on each split and keep the per-split differences.
  3. Report a corrected intervalApply the Nadeau-Bengio correction as in scikit-learn's example, and report the interval with the mean difference.
  4. Agree on the smallest gain worth shippingWrite it down before the experiment, so a lucky decimal can't move the goalposts.
  5. Break ties on costWhen the interval includes zero, prefer the simpler, cheaper or already deployed model, then confirm the choice once on the test set.

Key takeaways

  • A score on one split is one draw: on 143 rows, a single row is worth 0.7 points.
  • Compare models on identical splits and look at the per-split differences.
  • Fold scores overlap; correct the variance, or the test will find differences that aren't there.
  • Here a 0.7-point win became −0.33 points with an interval of −1.67 to +1.00: a tie, decided on cost.

📚 المصادر

  1. Statistical comparison of models using grid search — scikit-learn examples
  2. Common pitfalls and recommended practices: controlling randomness — scikit-learn
  3. Nadeau and Bengio, Inference for the Generalization Error (NeurIPS 1999)
  4. Bouthillier et al., Accounting for Variance in Machine Learning Benchmarks (arXiv 2021)

التعليقات (0)