Index Ai Academy
Glossary · Phase 3 · Machine learning

Majority baseline

The accuracy you get by always predicting the most common class. A model has to beat it to be worth anything.

What it means

The majority baseline, or majority-class baseline, is the accuracy you get by always predicting the most common class. It takes no learning at all. If 81% of customers stay, then always saying "stays" scores 81%.

It's the first number to compute for any classifier, because it tells you what an accuracy score is really worth. On this data, 80% accuracy isn't good. It's worse than doing nothing.

An example in Python

from collections import Counter

truth = ["stays"] * 81 + ["leaves"] * 19

# The majority baseline: always guess the most common class.
most_common, count = Counter(truth).most_common(1)[0]
print(f"majority baseline: always '{most_common}', accuracy {count / len(truth):.0%}")

# A model that finds 5 of the 19 who leave, but wrongly flags 8 who stay.
predicted = ["leaves"] * 8 + ["stays"] * 73 + ["leaves"] * 5 + ["stays"] * 14
right = sum(p == t for p, t in zip(predicted, truth))
print(f"model accuracy: {right / len(truth):.0%}")
What it prints
majority baseline: always 'stays', accuracy 81%
model accuracy: 78%

The model scores 78%, below the 81% baseline. Yet it found 5 of the 19 customers who leave, and the baseline finds none. So it isn't useless: accuracy is the wrong measure for it. When classes are unbalanced, look at precision and recall as well.

In practice

In scikit-learn, DummyClassifier(strategy="most_frequent") gives you this baseline, and you can score it like any other model. For predicting a number, the equivalent is always predicting the average. Either way, it's a floor to beat, not a goal.

Try it now

One score per class, turned into probabilities that add up to 1. Drag a score and watch every probability move.

Learn it properly

Multiclass classification · Softmax and cross-entropy for more than two classes. About 30 minutes.

Create a free account See what's in the lesson

Other terms from the same lesson

Never trained an AI?

Teach a small one to write, right in your browser. It takes about 20 seconds and needs no account.

Teach it to write