Majority baseline and held-out predictions
Quick answer
A baseline is a simple method used as a reference for evaluating another model. A majority-class baseline predicts the most frequent training label for every new sample. It can reveal whether a complex classifier adds value, but even a high baseline accuracy may hide costly errors or class imbalance.
Train on historical labels only
Our training labels are [1, 0, 1, 1], and three separate held-out labels are [0, 1, 0]. Fit using training labels only. Accuracy is the number of correct predictions divided by the number evaluated. Use exact counts first, then round only for display.
training = [1, 0, 1, 1]held_out = [0, 1, 0]majority = int(sum(training) > len(training) - sum(training))predictions = [majority] * len(held_out)correct = sum(int(a == b) for a, b in zip(held_out, predictions))print(predictions)print(correct)print(f"{correct / len(held_out):.3f}")Expected output:
[1, 1, 1]10.333The learned class is 1. The baseline gets one of three predictions right, so its exact accuracy is 1/3. The formatted decimal is rounded.
Compare a predeclared rule
Suppose the existing dispatch policy alerts when distance is at least 60 km. The held-out distances are [20, 80, 40], in the same order as their labels. Freeze this rule before evaluating these examples.
distances = [20, 80, 40]actual = [0, 1, 0]predictions = [int(d >= 60) for d in distances]correct = sum(int(a == b) for a, b in zip(actual, predictions))print(predictions)print(correct)print(f"{correct / len(actual):.3f}")Expected output:
[0, 1, 0]31.000The rule gets all three examples right. This toy result is not evidence of real-world superiority: three observations cannot establish reliable future performance.
Ties, empty inputs and honest comparisons
For training labels [0, 1], the two classes are equally frequent. Our explicit tie policy chooses 0; other classifiers may choose differently. Empty training data cannot determine a majority. Empty evaluation data cannot determine accuracy. Validate these cases instead of dividing by zero or silently reporting 0% accuracy.
In larger projects, use separate validation data to tune a model and an untouched test set for final evaluation. If you repeatedly change a rule after looking at a holdout, that holdout is no longer an independent final test.
Common mistake
Do not choose the majority using held-out labels, tune the 60 km threshold after seeing those labels, or report training accuracy as an estimate of future performance.
Practice and next steps
Milestone: fit the majority on [1, 0, 1, 1], evaluate on [0, 1, 0], compare with the fixed distance rule, and explain why neither method should be deployed on this evidence alone. Next chapter: reproducible Python experiments.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Majority baseline and held-out predictions — knowledge check
Apply the concepts from this lesson to small fictional scenarios.
Train labels [1, 0, 0, 0]. What is the majority prediction?
Train labels [1, 0]. What is the defined teaching tie result?
Predictions [1, 1, 1], true labels [0, 1, 0]. What is exact accuracy?
Which action invalidates an untouched final test?
What can we conclude from the rule scoring 3/3 in this tiny example?