AI Baseline Models
Compare a learned model with a deliberately simple alternative.
How it works
A baseline tells you what a model must improve upon. For regression, predict a training mean or median. For classification, predict a training majority label or use a simple domain rule. Compute the baseline from training data only and evaluate it on the same held-out cases as the more complex model.
Run the code
Try in playground loads this complete standard-library Python example without executing it. Choose Run when ready. Local review uses Python 3.12.14; the existing browser editor uses Pyodide 0.27.7. These small fictional examples need no account, external data, model-provider key or database service.
Example
from statistics import median
train_targets = [8, 9, 10, 17]
test_targets = [9, 13]
baseline = median(train_targets)
errors = [abs(baseline-y) for y in test_targets]
print("training median:", baseline)
print(f"held-out MAE: {sum(errors)/len(errors):.2f}")
Expected result
training median: 9.5 held-out MAE: 2.00
The median is 9.5 and stays fixed when predicting both held-out cases. A complex model that does worse on the same evaluation has not earned its extra complexity for this task. One tiny split is still too little evidence for deployment.