DEV Community

Japan Open Data Lab
Japan Open Data Lab

Posted on

Did Our Ensemble Actually Win? A 3-Step Fold Check on Walk-Forward Scores #2

TL;DR — When an ensemble beats a single model by 0.001 on a leaderboard metric, is that a win or fold noise? We ran a 3-step check — paired per-fold differences, spread-rescaled scores, rank aggregation — on three fold sets: our Store Sales walk-forward scores (RMSLE), our Fraud stratified scores (ROC-AUC, the non-temporal control), and a fully public airline-passengers run anyone can reproduce. Verdict: on the walk-forward folds the ensemble's first place survives all three steps, but its margin over the strongest single model is the only one that clears the fold-to-fold noise — and second place, separated by 0.00006 in the raw mean, collapses into a tie under rank aggregation. The ladder, and the order you climb it in, came out of a comment thread on DEV; this post is the write-up we promised there.

  1. Step 1 (paired differences) is the gatekeeper. Store Sales walk-forward: our ensemble beat CatBoost on 5 of 5 folds, mean difference −0.00107 RMSLE against a standard deviation of the differences of 0.00076 — the edge is larger than its own wobble. Against XGBoost it also won 4 of 5, but the mean difference (−0.00113) sits at the same level as its variation (0.00119): a lead, not a verdict.
  2. Steps 2 and 3 agree on first place and argue about second. Rescaling each fold by its spread and aggregating ranks both keep the ensemble first (mean rank 1.40). But CatBoost and XGBoost, separated by 0.00006 in the raw mean, tie at mean rank 2.60. If your roadmap depends on which single model is "second best", five folds cannot tell you.
  3. Split construction changes what the check can say. On stratified folds (Fraud, ROC-AUC), the ensemble beat every single model on every fold with a uniform edge (+0.00153 over CatBoost, SD 0.00040), and all three steps reproduce the full ordering exactly. On walk-forward folds, where fold difficulty genuinely varies (our easiest fold averaged ~0.371 RMSLE, the hardest ~0.407–0.428), the steps diverge — which is precisely when you need them.

Where the ladder came from

This check exists because of a comment. Under Senanur Çetin's post-mortem of a 0.128-vs-0.129 leaderboard gap, we proposed re-aggregating folds after subtracting each fold's mean difficulty — and she pointed out, correctly, that subtracting the same constant from every model in a fold cannot change any pairwise gap, so a plain mean can never reorder anything. Reordering requires rescaling by each fold's spread, or a non-mean aggregation such as ranks. She also proposed the sharper primary statistic: per-fold differences themselves — win counts, and the mean difference measured against its own fold-to-fold variation.

So the ladder, in the order we agreed in that thread:

  1. Paired per-fold differences — for each rival, the differences fold by fold: how many folds won, the mean difference, and the standard deviation of the differences. If the mean doesn't clear its own variation, stop calling it a win.
  2. Spread-rescaled scores — z-score within each fold, then average. This is the step that can reorder, because a win on a hard, high-spread fold counts for more than a win on an easy one.
  3. Rank aggregation — average each model's per-fold rank. Throws away magnitudes entirely; what survives is pure consistency.

The framing underneath is one our knowledge vault's papers support: validation has two different jobs. In a study of series-wise versus time-wise cross-validation across 11 datasets and 10 neural architectures (Cerqueira, Oliveira & Roque, arXiv:2611.08252), the split design that was better for model selection was slightly worse for error estimation. Choosing between models and estimating your score are different questions — this ladder is about the first one.

The check, in code

import numpy as np

def fold_check(scores, lower_better=True, ensemble="ensemble"):
    """scores: {model: [fold scores]}. Returns the 3-step ladder."""
    models = list(scores)
    arr = {m: np.array(v) for m, v in scores.items()}
    # Step 1: paired per-fold differences vs the ensemble
    for m in models:
        if m == ensemble:
            continue
        d = arr[ensemble] - arr[m]
        wins = int(np.sum(d < 0)) if lower_better else int(np.sum(d > 0))
        print(f"S1 vs {m}: wins {wins}/{len(d)}, "
              f"mean diff {d.mean():+.5f}, sd {d.std(ddof=1):.5f}")
    mat = np.stack([arr[m] for m in models])
    # Step 2: z-score within each fold, then average
    z = (mat - mat.mean(axis=0)) / mat.std(axis=0, ddof=1)
    print("S2 mean z:", {m: round(float(z[i].mean()), 3)
                         for i, m in enumerate(models)})
    # Step 3: mean per-fold rank
    ranks = np.zeros_like(mat, dtype=float)
    for f in range(mat.shape[1]):
        order = (np.argsort(mat[:, f]) if lower_better
                 else np.argsort(-mat[:, f]))
        for r, idx in enumerate(order):
            ranks[idx, f] = r + 1
    print("S3 mean rank:", {m: round(float(ranks[i].mean()), 2)
                            for i, m in enumerate(models)})
Enter fullscreen mode Exit fullscreen mode

Result 1 — Store Sales, walk-forward (our folds, statistics only)

Expanding walk-forward, five non-overlapping 16-day folds, RMSLE, four models. We publish the check's statistics rather than the raw fold table, because this board is still live.

  • Step 1: ensemble beats CatBoost 5/5 (mean −0.00107, SD 0.00076) — the one margin that clears its noise. Beats XGBoost 4/5 (−0.00113, SD 0.00119) and the state-space baseline 4/5 (−0.00897, SD 0.00795) — real leads, both inside or at the edge of their variation.
  • Step 2 (mean z): ensemble −0.557, CatBoost −0.297, XGBoost −0.100, baseline +0.954. Same order as the raw mean.
  • Step 3 (mean rank): ensemble 1.40, CatBoost 2.60, XGBoost 2.60, baseline 3.40.

Two honest details. First, the rank flip: on Fold 1, the plain state-space baseline beat every learned model — the fold where "more model" was simply worse, and a reminder that fold difficulty is not a scalar. Second, the second-place tie: the raw means separate CatBoost and XGBoost by 0.00006 RMSLE. That is not a measurement, it's a coin flip wearing a lab coat, and rank aggregation says so.

Result 2 — Fraud, stratified folds (the control)

Same ladder, different split construction: stratified random 5-fold, ROC-AUC, no time axis at all. The ensemble beat every single model on all five folds — CatBoost by +0.00153 (SD 0.00040), LightGBM by +0.00164 (SD 0.00036), RealMLP by +0.00219 (SD 0.00054). Step 2 puts the ensemble at z +1.424 with daylight behind it; Step 3 gives mean ranks of 1.00 / 2.20 / 2.80 / 4.00. All three steps, one ordering, no arguments.

That contrast is the point. Stratified folds are near-clones of each other, so fold differences there measure model consistency and little else. Walk-forward folds differ in difficulty by construction — which is why the ladder's steps can disagree there, and why a check that only makes sense on homogeneous folds would have told us nothing about the time-series case.

Result 3 — Airline passengers, fully public (reproduce this one)

The classic 144-month airline series, expanding walk-forward, 12-month horizon, five folds, RMSLE. Three models anyone can code in an afternoon: seasonal naive (mean 0.1074), Holt-Winters with fixed parameters (0.0896), and their simple average (0.0794).

  • Step 1: the average beats seasonal naive 4/5 (mean −0.0280, SD 0.0277 — borderline) and Holt-Winters 4/5 (mean −0.0102, SD 0.0239 — the difference is inside the fold noise).
  • Step 2: average −0.589, Holt-Winters −0.166, naive +0.754.
  • Step 3: mean ranks 1.40 / 2.00 / 2.60.

So the public run lands the honest ending: the ensemble tops every aggregation, and the paired differences still refuse to certify its edge over the stronger single model. "First on average" and "measurably better" are different claims, and five folds often only buy you the first.

Our judgment

  • Run Step 1 before you celebrate or mourn a small gap. A mean difference that doesn't clear the standard deviation of its own differences is a hypothesis, not a result. Budget your next iteration accordingly.
  • Use ranks when you suspect one fold is doing all the talking — a rank flip like our Fold 1 baseline win moves a mean; it barely moves a rank table.
  • Use rescaling when fold difficulty varies by design (walk-forward, grouped splits). It is the only aggregation of the three that prices a win on a hard fold above a win on an easy one.
  • And none of this fixes a bad split. The ladder audits comparisons within a fold set. If the split leaks, all three steps will confidently certify a leak.

What didn't work / Limitations

  • Five folds is five folds. Every statistic here is computed on n=5 differences. The SD of differences is itself a rough estimate at that size; treat "clears its noise" as a working rule, not a significance test.
  • The Store Sales folds were re-measured for this check with the existing pipeline's configuration and weights unchanged — the honest way to get a clean fold table, but a re-measurement, and we label it as such. The Fraud folds come from an existing stratified cache; Fraud has no date column, which is why no walk-forward version of it exists here.
  • The public run uses two classical forecasters, not the neural models of the paper cited above. It demonstrates the ladder, not the state of the art.
  • The check compares models on one metric at a time. It says nothing about calibration, cost, or whether the winning ensemble is worth its complexity in production — only whether its fold-level lead is distinguishable from fold noise.

This write-up fulfills a promise made in a comment thread: the discussion started under Senanur Çetin's ensemble post-mortem, where the ladder's design was argued out in the open — including the part where our first proposal couldn't have worked. That is where this post's method comes from, and the thread is worth reading alongside it.

When two of your models land within a hair of each other on cross-validation, what do you actually look at before picking one — the fold table, a paired difference, or the leaderboard?

Get the next experiment logs and model release notes by email: https://jpopendata.jp/ (newsletter signup in the footer).

Top comments (2)

Collapse
 
alcyo_a702f7e3a9d20a profile image
alcyone-growth •

Calling out that 0.00006 raw-mean gap collapsing into a tie under rank aggregation is spot-on. When moving walk-forward benchmarks into a paper table, printing mean ± SD across folds and programmatically bolding only statistically clear winners (rather than hand-bolding raw means in LaTeX booktabs at 2 AM) stops tiny fold wobble from looking like a decisive margin.

Collapse
 
japanopendatalab profile image
Japan Open Data Lab •

Thank you — that 0.00006 gap is exactly why we stopped trusting the raw mean table on its own. In the code we printed for the check, Step 1 reports the mean paired difference next to its SD, and we only called the ensemble's margin over CatBoost (−0.00107 against SD 0.00076) a clear win; the CatBoost/XGBoost ordering we left as a tie at mean rank 2.60. Programmatic bolding based on that rule is a good discipline — hand-bolding the smallest mean would have crowned a second place that five folds simply cannot separate.