Skip to content

A baseline first

A score means nothing until you know what a model that ignores every feature would get. Build the ladder from baseline to glass box to strong learner.

Introductory ~10 min8 steps

What runs in CodeSplash

You will be able to

  • Say what the no-feature baseline predicts for each task
  • Compute how much of the baseline's error a model removes
  • Follow the ladder from baseline to glass box to strong learner

Read first

01

Is that score good?

Read

A colleague reports 92% accuracy. Is that good? You can't tell. If 92% of rows belong to one class, a rule that always says that class gets 92% and has learned nothing.

Baseline (no features) is the reference row of every leaderboard. It ignores the features and predicts:

TaskIt predicts
RegressionThe training mean, or the median
Classes, with Class prediction as priorThe class shares
Classes, with most frequentThe commonest class, always
02

What will a lazy rule score?

Predict

Predict first

Three penguin species, and Adelie is the commonest. A rule that always says "Adelie" uses no measurements at all. What accuracy will it reach?

Make your guess between 0 and 1 accuracy, then reveal.

Reveal

44% across folds. A boosted model on real measurements gets 98%. The distance between those two is what the features earned.

03

Rare classes hide everything

Explore

Set Share of positives to a low value and read Always negative. Now raise How well the score separates and move the Decision threshold, and watch accuracy barely beat that lazy score even when the model finds real cases.

HExplorable · Rare events and the decision threshold

Why can a 98% accurate model be useless, and where should the threshold go?

A lazy model calls every case negative. What accuracy does it score?

0.500
How sure?
0.020
1.5
1.50
20
5000
threshold
flaggedpassed
pos5262
neg3124574

Bars are drawn to one count scale, so a rare positive class looks as rare as it is. The ROC curve barely notices the imbalance; the precision–recall curve shows it. Cheapest threshold here: 1.14; the binormal formula gives 1.35.

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

Baselines in numbers

Read

The baseline's score depends on the metric:

  • ROC AUC: with no ranking information it's 0.500, whatever the class balance.
  • RMSE: about the target's standard deviation. For ozone that's 34.6.
  • Grouped data: the median baseline for chick weights scores 77.3, with whole chicks held out.

So a linear model at 22.9 on ozone has earned its place. An AUC near 0.500 has not.

05

The ladder

Read

Work up, and stop when the next rung stops paying.

  1. Baseline: what you get for nothing.
  2. Glass box: linear, logistic or a small tree. Often close to the best, and you can read it.
  3. Strong learner: forest or boosting, on the same folds.
  4. Tune only the learner that earned it.

If step 3 beats step 2 by less than fold-to-fold noise, the glass box usually wins: it's easier to explain, to check and to keep running.

06

Check your understanding

Checkpoint

Check yourself

A model has an accuracy of 95% where 95% of the rows are negative. What should you conclude?

Show the answer

Answer: b

Accuracy can be fine when you read it against the baseline. Here the model has shown nothing beyond the base rate.

Check yourself

A baseline's RMSE is 40 and your model's is 20. What share of the baseline's RMSE did it remove? Answer as a proportion.

Show the answer

Answer: 0.5

1−20/40=0.51 - 20/40 = 0.5. In terms of MSE that's three quarters, since 1−202/402=0.751 - 20^2/40^2 = 0.75. That second figure is the R2R^2, so always say which you mean.

Check yourself

A strong learner beats a logistic model by less than the fold-to-fold spread. What does the ladder suggest?

Show the answer

Answer: a

A lead within noise isn't evidence of a better model. The ladder asks each rung to earn its extra complexity.

07

Train the ladder

In the app

In the Learners step, select Baseline (no features), Linear / logistic regression and one strong learner, then press Train 3 models. The Leaderboard ranks them by cross-validated score, and each row shows how far it is from the best. The walkthrough trains a baseline and a forest to predict {{target}}.

Python
import pandas as pd
from sklearn.dummy import DummyClassifier
from sklearn.model_selection import cross_val_score

df = pd.read_csv("penguins.csv")
X, y = df[["bill_len"]].fillna(0), df["species"]
lazy = DummyClassifier(strategy="most_frequent")
print(cross_val_score(lazy, X, y, cv=5, scoring="accuracy").mean())
R
df <- read.csv("penguins.csv")
max(table(df$species)) / nrow(df)
08

Recap

Recap
  • Read every score against a no-feature baseline, on the same folds.
  • With rare classes, a lazy rule can look excellent on accuracy.
  • Climb from baseline to glass box to strong learner, and stop when the next rung stops paying.

Concepts in this lesson