What Must a Model Improve On?
A complicated predictor needs a simple comparison. Before fitting one, we can measure how well a rule that always predicts a training average performs on new observations.
12 sections · 3 questions · 2 coding challenges
The arrow keys move between sections too.
A Prediction Needs a Reference for Comparison
BOTIE
Modern evaluation libraries preserve this practice through baseline estimators that ignore input features and predict a training summary. This is not an invention claim for one library. Our invented greenhouse example uses the training mean to make the comparison explicit before introducing more capable predictors.
Sources for this history
Would the Average Have Done Just as Well?
Botie has a new model for greenhouse temperature. Its reported error sounds small. But could we get a similar result by predicting the training average every time? Let's measure that simple rule before deciding whether the new model is helping.
We will start with a deliberately limited predictor: use the average training temperature for every new observation. That gives us a baseline, a result the more elaborate method should improve under the same evaluation conditions.
The training readings and held-out temperatures are invented, separate samples.
Step 1 of 3
Learn a single training reference
The baseline sees the training outcomes and no features. Its only fitted value is their mean.
Training temperatures: [10, 14, 18] Reference = (10 + 14 + 18) / 3 = 14
Step 2 of 3
Predict before inspecting the answers
Every held-out observation receives that same reference. The held-out answers do not change it.
| Same observation | Predictions | Held-out temperatures |
|---|---|---|
| Held-out reading 1 | 14 | 12 |
| Held-out reading 2 | 14 | 20 |
Held-out reading 1
- Predictions
- 14
- Held-out temperatures
- 12
Held-out reading 2
- Predictions
- 14
- Held-out temperatures
- 20
Step 3 of 3
Measure the errors
The baseline overpredicts one observation and underpredicts the other. Squaring keeps their sizes from cancelling.
| Same observation | Errors | Squared errors |
|---|---|---|
| Held-out reading 1 | 2 | 4 |
| Held-out reading 2 | -6 | 36 |
Held-out reading 1
- Errors
- 2
- Squared errors
- 4
Held-out reading 2
- Errors
- -6
- Squared errors
- 36
A baseline has to respect the same information boundary
The training branch supplies the prediction. Only the scoring branch reads the held-out answers.
What score does a constant prediction earn?
Fit one temperature from the training readings and use it for every held-out case. Changing a held-out answer should change the error, but it must not change that fitted prediction.
BOTIE
Held-out error of the fitted constant
20
Follow the operations
1. Training temperatures
- 010
- 114
- 218
2. Mean
14
3. Held-out temperatures
- 012
- 120
4. Subtract
- 02
- 1-6
5. Square
- 04
- 136
6. Mean
20
7. Result
20
This baseline uses no input features. Its score is a comparison, not a guarantee of acceptable temperature prediction.
1. Choose a Baseline That Matches the Task
A regression baseline might predict a mean or median. A classification baseline might use the majority class. A forecast might repeat the latest observation or the matching season. The baseline should be simple but relevant.
For our temperature example we will use the mean, because we will score squared errors. Among constant predictions, the training mean minimises the sum of squared training errors.
Training mean = (10 + 14 + 18) / 3 = 14This fitted constant ignores inputs such as sunlight and heating settings. It establishes what we can achieve before using those features.
2. Freeze the Rule Before Evaluating It
Apply the fitted constant to held-out observations. Do not replace it with the held-out mean. That would use information the predictor did not have when making those predictions.
Held-out predictions: [14, 14]
Held-out answers: [12, 20]
Errors: [2, -6]A baseline must obey the same information boundary as the model it is compared with.
3. Score Both Methods on the Same Observations
Mean squared error averages the squared differences between predictions and answers. We need the same units, same held-out examples, and same metric for a fair comparison.
Baseline MSE = (2² + (-6)²) / 2
= (4 + 36) / 2
= 20A model with lower error on different examples has not yet won this comparison. Shared evaluation examples let us compare their mistakes directly.
4. Ask What an Improvement Actually Buys
A small reduction in average error may not justify greater latency, maintenance, or instability. Inspect which observations improve and which get worse. Repeat the evaluation when the dataset is small or the fitting procedure is variable.
The baseline is a reference, not a target that guarantees usefulness once beaten. A temperature predictor may still be unsuitable for a particular control decision even after improving its average score.
The workshop builds the whole baseline evaluation from training outcomes and held-out answers. It must not learn its constant from the test branch.
5. The Best Constant Depends on How We Measure Error
If Botie must predict one temperature for every greenhouse, squared error favours the training mean. Absolute error favours a training median. A baseline is therefore part of the evaluation design, not an arbitrary weak opponent.
Keep its fitted value fixed on held-out rows. Taking the test mean gives the baseline access to the answers. For classification, a majority-label baseline and a constant class-probability baseline serve different metrics and should be named accordingly.
6. One Extreme Reading Separates Two Constant Rules
A distant reading pulls the mean because squaring makes a large residual expensive. The median depends on ordering and is less affected by the size of that extreme. Neither is universally better: they minimise different losses.
Compare candidate models with a baseline that is appropriate to the same target, loss and information available at prediction time.
Score both constants under both losses
The example is a training calculation to explain the loss, not a held-out performance claim.
import numpy as np
y = np.array([10., 11., 12., 40.])
for value in [y.mean(), np.median(y)]:
print(float(value), round(float(np.abs(y-value).mean()), 3), round(float(((y-value)**2).mean()), 3))18.25 10.875 158.188
11.5 7.75 203.75The mean wins squared error and the median wins absolute error. The baseline must answer the metric we intend to use.
Check yourself
Questions on Parts 1 to 6
Question 1 of 3
Which data determine the baseline's constant?
Try it with Botie
Build with Botie
Write and run Python