internalsGet Pro

Module 01 · Lesson 8 of 10Free

Baselines: the simple model to beat

Level
Beginner
Topic
Machine learning fundamentals
Reading time
13 min

When you finish this page you can

  1. Explain why a model’s score means nothing until you compare it with a baseline measured the same way.
  2. Build three kinds of baseline for a prediction: no learning, a simple rule and a simple model.
  3. Decide which baseline a new model must beat before it replaces what runs today.
  4. Spot an unfair comparison, and a score that is suspiciously far above or below its baselines.

Builds on 2 lessons

Start with lesson 112 min
  1. Introduction to machine learning engineering12 min
  2. When not to use machine learning12 min
0:00 / 4:28
Show transcript

0:00 Meet Farah, the machine learning engineer at Kartly, our example online store. She has built a churn model. Churn means customers who stop buying, and the model picks which ones get a voucher each Monday. Joseph leads the growth team. He sends twenty thousand vouchers every week. Farah tests the model on last quarter, when Kartly already knows who left. It is right about eighty-five percent of the time. Joseph likes that number. Then Joseph asks a fair question. What would a lazy answer score? Say the lazy answer is that nobody leaves. Last quarter, thirteen percent of customers stopped buying. So the rest stayed, and saying nobody leaves is right for every one of them. That scores eighty-seven percent. It beats Farah’s model, yet it sends no vouchers at all. A score on its own tells you nothing. You need to know what the simplest answer scores.

0:41 The simple answer has a name. It is a baseline. A baseline is the score of a simpler approach, measured on the same customers with the same score. Think of it as the bar the model has to clear. The model’s number is only worth the gap above that bar. Farah uses three kinds, from cheapest to strongest. The first is no learning. That means a random list, or the answer nobody leaves. It is almost free. If the model loses even to this, something is broken: the answers it learned from, the code or the score. The second is a simple rule. At Kartly, that is the rule they run today. If the model loses to it, keep the rule. The third is a simple model, built on just a few inputs. If the complex model loses to it, ship the simple one. Each score has its own no-learning baseline. For accuracy, which is the share of customers labelled correctly, it is nobody leaves. For Joseph’s list, it is a random twenty thousand customers. So before comparing anything, Farah picks the score Joseph cares about.

1:34 Here is Joseph’s score. Out of the twenty thousand vouchers, how many reach a customer who really left? Farah measures every approach this way, on the same past Monday. Think of each approach as a rung on a ladder. We climb it from the bottom. The bottom rung is the random list. With no information, it reaches leavers at the rate they occur. That is thirteen percent. The next rung is the rule Kartly runs today. It uses just the days since each customer’s last order. It reaches thirty percent, more than double the random list. The top rung is the churn model. It reaches forty percent. Now look at what the model really adds. It is not the forty percent. It is the two thousand extra leavers reached each week, compared with the rule. The rule did most of the work. The model has to earn the rest.

2:17 So what must the model beat before it replaces the rule? Beating a random list is not enough. Almost any model passes, and that only shows the data has some signal. Beating the rule is better. But a model just above it can still lose money once its running cost is counted. The right bar is the rule, by enough to pay for the model, on the same customers. Kartly already worked out the break-even. That is the score where the model just pays for itself. It is about thirty-four point eight percent. The churn model reaches forty. So the switch pays, and Joseph gets a clear yes in his own unit. The bar moves as Kartly changes. Once the model is live, it becomes the baseline. A new version at fifty-one percent must beat the live model’s forty. If nothing runs today, the baseline is the simplest thing that could ship this week. And before building a complex model, train a simple one first. It gives you a baseline to test the complex ones against.

3:08 A fair comparison needs the same test. Suppose Farah quotes the rule’s score from a report written before the festival sale. And she quotes the model’s score from last quarter. The gap may come from the season, not the model. So Farah keeps four things the same. The customers: one past Monday, never seen in training. The cut: the top twenty thousand from each approach. What counts as leaving: no order in the sixty days after that Monday. And what each approach may know: only orders up to that Monday. Baselines also warn you when a score cannot be trusted. A model below the random list has a bug, such as a list sorted the wrong way. A model far above every rung, say ninety percent, usually read something it could not have known on that Monday. That mistake is called data leakage, and a later lesson shows how to find it.

3:54 Let us recap. One: a score is good only if it beats a baseline measured the same way, on the same customers and the same window. Two: use three kinds of baseline, no learning, a simple rule and a simple model. Three: the bar is what you would ship otherwise, by enough to pay for the model. Four: once a model is live, it becomes the next baseline. Five: a score below the no-learning baseline means a bug, and one far above every rung usually means leakage. The rule reads just the days since each order. The model reads many things, and learns from past answers. What those inputs and answers are comes next, in Data, features and labels.

Right about 85% of customers, and still behind a guess

is our example online store. Its ML team works on a notebook sample of about 1 million orders, 200,000 customers and 50,000 products. Every Monday, Joseph’s growth team sends 20,000 vouchers of ₹100 to customers who might stop buying. Today a 60-day rule picks them: the customers with the longest gap since their last order go first.

Farah, Kartly’s ML engineer, has trained a model to pick the list instead. She replays it on last quarter’s customers, where Kartly already knows who left. Her model flags its top 20,000 as leavers and everyone else as stayers. It is right about 85% of the 200,000 customers.

Joseph likes the number. Then he asks what a lazy answer would score.

Check yourselfAnswer in your head first, then reveal
On last quarter’s customers, 13% stopped buying. A “model” that answers “stays” for every customer flags nobody. What share of customers does it get right?Show answerHide answer
87%: every one of the 87% who stayed. That beats Farah’s 85%, yet it would send no vouchers at all. A score on its own says nothing until you know what the simplest answer scores.
The answer that does nothing scores higher than the model. The score that matters to Joseph is leavers found.

The share of customers a model labels correctly is its accuracy. Google’s course gives the same warning: when one answer is rare, a model that always predicts the common answer can score high and still be useless.3 Choosing the right score is taught in Choosing a metric that matches the goal.

So the question this lesson answers is: how do you tell whether a model’s score is good?

A score means something only next to a baseline

A is the score of a simpler approach, measured on the same customers with the same score. The model’s number is only worth the gap above it.

Farah uses three kinds, from cheapest to strongest:

Baseline At Kartly If the model beats it If the model loses to it
No learning A random list; “nobody leaves” There is some signal in the data Something is broken: labels, code or score
A simple rule The 60-day rule Kartly runs today The model adds something people didn’t already know Keep the rule
A simple model A small model on two or three inputs The complex model earns its extra parts Ship the simple model

The first kind is close to free. scikit-learn ships it as DummyClassifier: it ignores the inputs and is meant as a simple baseline for other classifiers.2 One of its options always predicts the most common answer, which is the “nobody leaves” answer above.2

Each score has its own no-learning baseline. For accuracy, it is “nobody leaves”. For Joseph’s list, it is a random 20,000 customers. So before comparing models, Farah picks the score Joseph cares about.

The Monday list, rung by rung

Joseph’s score is the share of the 20,000 vouchers that reach a customer who really left. This is the model’s on the list; Precision and recall covers it fully. Farah scores each approach on the same past Monday.

Random list

13% of 20,000 = 2,600 real leavers reached

With no information, the list reaches leavers at the rate they occur.

60-day rule

30% of 20,000 = 6,000, so 3,400 more than random

One number per customer, days since the last order, more than doubles the random list.

Churn model

40% of 20,000 = 8,000, so 2,000 more than the rule

The model’s real gain is these 2,000 a week, not its 40%.

Every number here is this lesson’s scenario, not a measurement.

Read the model’s score as a gap above each rung. Only the gap above the rule, past break-even, pays for the model.

The rule did most of the work. Google’s guide to ML engineering expects this: if a model gives a 100% gain, a simple rule gets you about half of it.1 The model has to earn the rest.

The bar is what you would do otherwise

What must Farah’s churn model beat before it replaces the 60-day rule?

A random list.

Almost any model passes. It proves the data has signal, but not that Kartly should switch.

The 60-day rule.

Proves the model adds something. But a model at 33% passes too, and it loses money once the system’s running cost is counted.

Why this choice

The baseline that matters is the one you would ship if the model did not exist. Today that is the rule. When not to use machine learning worked out the break-even: about 34.8%, for a system costing ₹10 lakh a year.

The weaker rungs still earn their place. They are sanity checks, and they show how much of the gain the rule already gives.

The bar moves as Kartly changes:

  • Once the model is live, it becomes the baseline. A new version at 51% has to beat 40%, not 30%, and pay for its own extra cost.
  • If nothing runs today, the baseline is the simplest thing that could ship this week, such as a rule Joseph can write down.
  • Before a complex model, train a simple one. Google’s guide says the first model gives the biggest gain, and a simple model gives the baseline metrics to test complex ones against.1 A small logistic regression on two or three inputs is a common choice.

A baseline only counts on the same customers

Farah’s 40% beats the rule only if both numbers come from the same test. Suppose she quotes the rule’s 30% from a report written before the festival sale, and the model’s 40% from last quarter. The gap may come from the season, not the model.

A fair comparison keeps four things the same:

Keep the same At Kartly
The customers One past Monday’s 200,000, never seen in training
The cut Top 20,000 from each approach
What counts as leaving No order in the 60 days after that Monday
What each approach may know Only orders up to that Monday
Same Monday, same history, same 60-day window. Only then can the three scores sit side by side.

The baselines also warn when a model’s score can’t be trusted. A model below the random list has a bug, such as a list sorted the wrong way. A model far above every rung, say 90%, usually read something it couldn’t know on that Monday. That mistake is called ; Data leakage shows how to find it.

The rule’s own vouchers change who left

On a real past Monday, the rule’s 20,000 customers got a voucher, and some of them stayed because of it. In this scenario about 1 in 20 reached leavers stays. So the rule’s list shows slightly fewer leavers than it really found, and the model looks a little better than it is. Farah avoids this by counting only customers who got no voucher, such as the 1,000 she holds out each week. The cleanest comparison runs both lists on live Mondays, covered in A/B testing ML models.

Try it yourself

This runs in a free Colab or Kaggle notebook, or on a laptop with NumPy and scikit-learn, in a few seconds. It makes up 200,000 customers, then scores a no-learning baseline, the 60-day rule and a made-up model the same way:

Python
import numpy as np
from sklearn.dummy import DummyClassifier

rng = np.random.default_rng(42)
n = 200_000                    # customers in Kartly's notebook sample
left = rng.random(n) < 0.13    # made-up: 13% really stopped buying

# Made-up data: leavers have longer gaps since their last order on average.
days_quiet = np.where(left, rng.exponential(47, n), rng.exponential(27, n))
model_score = 1.0 * left + rng.normal(0, 1, n)  # a made-up churn model
VOUCHERS = 20_000


def share_reached(score: np.ndarray) -> float:
    """Share of the top 20,000 customers by score who really left."""
    top = np.argsort(score)[-VOUCHERS:]
    return float(left[top].mean())


no_inputs = np.zeros((n, 1))  # DummyClassifier ignores its inputs
dummy = DummyClassifier(strategy="most_frequent").fit(no_inputs, left)
nobody_leaves = dummy.predict(no_inputs)

flagged = np.zeros(n, dtype=bool)
flagged[np.argsort(model_score)[-VOUCHERS:]] = True

print(f"Accuracy, nobody leaves: {(nobody_leaves == left).mean():.1%}")
print(f"Accuracy, churn model:   {(flagged == left).mean():.1%}")
print(f"Leavers reached, random list: {share_reached(rng.random(n)):.1%}")
print(f"Leavers reached, 60-day rule: {share_reached(days_quiet):.1%}")
print(f"Leavers reached, churn model: {share_reached(model_score):.1%}")

Expect about 87% and 85% for accuracy, then about 13%, 30% and 40% for leavers reached. These are expected values worked out from the made-up data, not measured results; your run will differ by about a point.

What to look for: the two scores rank the same approaches in opposite orders. Then flip the model’s sort by changing [-VOUCHERS:] to [:VOUCHERS] in share_reached. The model drops well below the random list, which is how a baseline catches a bug.

Baselines for other predictions

The same three kinds work for any prediction. The no-learning baseline changes with the question:

Prediction No learning Simple rule or model
Will a customer leave? Random list; “nobody leaves” The 60-day rule
How long will a Rydo trip take? The average trip time Distance divided by the city’s usual speed at that hour
How many units will sell next week? Last week’s sales Sales in the same week last year
Which products to show? The most popular products this week Popular products in the customer’s usual categories
Which tags fit a product? The most common tag A prompted language model

Forecasting has standard names for two of these: the naive forecast repeats the last value, and the seasonal naive forecast repeats the value from the same season last year.

Where this shows up

The 60-day rule reads one number about each customer. The model reads many, and learns from past answers. What those inputs and answers are is the next lesson.

Common mistakes

  • Reporting a score with no baseline. “85% accurate” sounds good and is worse than doing nothing here.
  • Picking a weak baseline. Beating a random list is easy. Compare with what you would ship otherwise.
  • Comparing across different tests. Different customers, months or windows make the gap meaningless.
  • Giving the baseline less care. A rule checked on old data against a freshly tuned model flatters the model.
  • Celebrating a huge jump. A model far above every rung usually leaked the answer.

Check your understanding

Check yourselfAnswer in your head first, then reveal
Farah’s first try at the churn model reaches 11% of leavers on the Monday list. The random list reaches 13%. What should she suspect?Show answerHide answer
A bug, not a weak model. Doing worse than random usually means the list is sorted the wrong way or the labels are flipped. Not “the model needs more data”: even a useless model should land near 13%.
Check yourselfAnswer in your head first, then reveal
The churn model is live at 40%. A new version reaches 51% on the same Monday. Which baseline decides whether it ships?Show answerHide answer
The live model at 40%, not the 60-day rule. The new version must beat what Kartly runs now, by enough to pay for any extra cost. Comparing it with the rule’s 30% would overstate its gain.
Check yourselfAnswer in your head first, then reveal
Joseph’s team builds a model for next week’s sales of rice. It is off by 12% on average. Last week’s sales, used as the forecast, are off by 10%. What does Joseph do?Show answerHide answer
Keep last week’s sales as the forecast. The model loses to the naive baseline, so it adds cost without benefit. Its 12% sounded acceptable only because nobody measured the simple option.
Check yourselfAnswer in your head first, then reveal
A new churn model reaches 93% on the Monday list. What should Farah check first?Show answerHide answer
Whether the model read anything from after that Monday. A jump that far above every baseline usually means data leakage, such as a feature that counts later orders. Not “ship it”: a score that good is a reason to look for a bug.

Summary

  1. A model’s score is good only if it beats a baseline measured on the same customers, with the same score, the same cut and the same window.
  2. Use three kinds: no learning (random or the most common answer), a simple rule, and a simple model. Each tells you something different.
  3. The bar is what you would ship otherwise, by enough to pay for the model: at Kartly, the 60-day rule’s 30%, with break-even at 34.8%.
  4. Once a model is live, it becomes the baseline for the next version.
  5. A model below the no-learning baseline has a bug; one far above every rung usually leaked the answer.

Report a mistake

Tell us what’s wrong in this lesson and we’ll fix it.