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.
What runs in CodeSplash
- Baseline (no features) Verified in Python and R
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
Is that score good?
ReadA 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:
| Task | It predicts |
|---|---|
| Regression | The training mean, or the median |
| Classes, with Class prediction as prior | The class shares |
| Classes, with most frequent | The commonest class, always |
What will a lazy rule score?
PredictPredict 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.
Rare classes hide everything
ExploreSet 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?
| flagged | passed | |
|---|---|---|
| pos | 52 | 62 |
| neg | 312 | 4574 |
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 to see the result.
Baselines in numbers
ReadThe 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.
The ladder
ReadWork up, and stop when the next rung stops paying.
- Baseline: what you get for nothing.
- Glass box: linear, logistic or a small tree. Often close to the best, and you can read it.
- Strong learner: forest or boosting, on the same folds.
- 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.
Check your understanding
CheckpointCheck 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
. In terms of MSE that's three quarters, since . That second figure is the , 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.
Train the ladder
In the appIn 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}}.
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())df <- read.csv("penguins.csv")
max(table(df$species)) / nrow(df)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