Skip to content

When more model lowers error: averaging and double descent

Averaging many wobbly models removes variance without adding bias, and very large models can improve again past the point where they fit every row.

Advanced ~12 min8 steps

What runs in CodeSplash

You will be able to

  • Explain why averaging lowers variance but leaves bias alone
  • Describe double descent and what it does and doesn't overturn
  • Use a seed ensemble as a direct measure of seed variance

Read first

01

Why averaging works

Read

Take mm models, each with variance σ2\sigma^2 and pairwise correlation ρ\rho. The average has variance

ρ σ2+1−ρm σ2\rho\,\sigma^2 + \frac{1-\rho}{m}\,\sigma^2

The second term shrinks with more models. The first is a floor, set by how alike they are. Bias stays what it was: an average of models that all miss in the same way still misses.

So you want models that are individually flexible, and different from one another.

02

One tree or many?

Predict

Predict first

A single tree on Pima has a cross-validated AUC of 0.777. Average 500 deep trees, each on a bootstrap sample. What happens?

About the sameA clear improvementWorse, because more trees overfit
Reveal

A clear improvement: AUC 0.835. For ozone, RMSE falls from 22.6 for a pruned tree to 19.0 for the forest. Each tree is overfit in its own way, and the average cancels what they don't share.

03

Bag some trees

Explore

With One tree or a bag of trees, raise Trees in the bag and read Variance, the bag against Variance, one tree. Then press bag tree stumps: averaging shallow trees changes almost nothing, since bias is what they have.

DExplorable · Averaging models, and going past the interpolation point

When can adding more model lower the error instead of raising it?

Classical advice says more model means more variance. Going much further here (25 trees instead of one, or six times as many features as rows) will make predictions on new data…

How sure?

Experiment

25
6
40
0.30
Simulating…

Commit your prediction above to see the result

Make your prediction first; the figure appears when you commit.

Make your prediction to see the result.

04

Past the interpolation point

Explore

Switch Experiment to Up to six times more features than rows. Test error climbs to a peak where the model first fits every row exactly, then falls as features keep growing. That's double descentDouble descentTest error peaks where a model first fits every row exactly, then falls again as it grows further..

DExplorable · Averaging models, and going past the interpolation point

When can adding more model lower the error instead of raising it?

Classical advice says more model means more variance. Going much further here (25 trees instead of one, or six times as many features as rows) will make predictions on new data…

How sure?

Experiment

25
6
40
0.30
Simulating…

Commit your prediction above to see the result

Make your prediction first; the figure appears when you commit.

Make your prediction to see the result.

Past the peak, many rules fit the rows exactly, and the fitting method picks the smoothest. The extra size acts as an implicit brake.

05

What this doesn't overturn

Read

Double descent doesn't say that bigger is always better. The peak is real, and it's worst near where parameters match rows. Most tabular models live far to the left of it, where the classic curve still applies.

Validate on held-out rows either way. Neither curve is a reason to skip that.

06

Check your understanding

Checkpoint

Check yourself

Each model has variance 1 and pairwise correlation ρ=0.2\rho = 0.2. What is the variance of the average of 10 models?

Show the answer

Answer: 0.28

0.2+(1−0.2)/10=0.280.2 + (1 - 0.2)/10 = 0.28. With a million models you'd still have 0.20.2: the floor is set by how alike they are.

Check yourself

Why does bagging help deep trees far more than stumps?

Show the answer

Answer: a

A stump is wrong in about the same way on each resample. Boosting is the method that attacks that bias.

Check yourself

Where is test error at its worst in the double-descent experiment?

Show the answer

Answer: b

At that point the one rule that fits exactly has to bend violently through the noise. With more parameters, a gentler rule can fit as well.

07

Average your own

In the app

Open a run, go to Diagnostics and use Seed ensemble. It re-fits with Extra seeds on the same folds and averages them. The result joins the Leaderboard with an ensemble badge, so you can compare it directly. Its gap from the single run shows how much the seed alone was costing you.

Python
import pandas as pd
from sklearn.ensemble import BaggingClassifier
from sklearn.model_selection import StratifiedKFold, cross_val_score
from sklearn.tree import DecisionTreeClassifier

df = pd.read_csv("pima.csv")
X, y = df.drop(columns="diabetic"), df["diabetic"]
cv = StratifiedKFold(5, shuffle=True, random_state=1)
for depth in [1, None]:
    one = DecisionTreeClassifier(max_depth=depth, random_state=1)
    bag = BaggingClassifier(one, n_estimators=100, random_state=1)
    print(depth, cross_val_score(one, X, y, cv=cv, scoring="roc_auc").mean().round(3),
          cross_val_score(bag, X, y, cv=cv, scoring="roc_auc").mean().round(3))
R
library(rpart)
df <- rbind(MASS::Pima.tr, MASS::Pima.te)
set.seed(1)
fold <- sample(rep(1:5, length.out = nrow(df)))
for (depth in c(1, 20)) {
  ctl <- rpart.control(maxdepth = depth, cp = 0, minsplit = 2)
  one <- bag <- numeric(nrow(df))
  for (k in 1:5) {
    tr <- df[fold != k, ]; te <- df[fold == k, ]
    one[fold == k] <- predict(rpart(type ~ ., tr, control = ctl), te)[, "Yes"]
    p <- replicate(100, predict(rpart(type ~ ., tr[sample(nrow(tr), replace = TRUE), ], control = ctl), te)[, "Yes"])
    bag[fold == k] <- rowMeans(p)
  }
  cat(depth, round(as.numeric(pROC::auc(df$type, one, quiet = TRUE)), 3),
      round(as.numeric(pROC::auc(df$type, bag, quiet = TRUE)), 3), "\n")
}
08

Recap

Recap
  • Averaging reduces variance towards a floor set by how alike the models are, and leaves bias alone.
  • Bag flexible models, and make them different from each other.
  • Double descent is real past the interpolation point, but it's no reason to skip validation.

Concepts in this lesson