ML Practitioner

Case File: The Baseline to Beat

Before anyone believes a prediction, ask what a model that knows nothing would score. Compute the baseline that every real model must beat: always guess the mean, always guess the median, always guess "on time". Mean absolute error and accuracy, in real pandas on trips generated for you alone.

55 min

Sabi Logistics · Prediction 1

The Baseline to Beat

A vendor says their 'AI' predicts delivery times, and wants a contract signed on Friday

Chidi Founder · Phone call

Chidi. A vendor is in my office with a very shiny presentation. Their “AI” will predict how long each of our trips will take, and they have a slide that says their model is “within 9 minutes on average”. They want a three-year contract, and they want it signed on Friday.

I have no idea whether nine minutes is good. Maybe our trips only vary by ten minutes anyway. Before I hear another word about their technology, tell me: if we knew nothing and just guessed the same number every time, how wrong would we be? And if we only wanted to know whether a trip is late, how often would “always on time” be right?

I want the number their model has to beat.

The brief

What you need to know first.

  • A model is a rule that turns what you know about a trip (distance, parcels, weather) into a prediction (minutes, or late or not). Machine learning means the rule is learned from past data instead of written by a person.
  • Every prediction has an error: how far it was from the truth. Mean absolute error (MAE) is the average size of the misses, ignoring direction: (actual - predicted).abs().mean(). An MAE of 9 means “on average, off by 9 minutes”. Unlike a squared error, it is in the units you care about.
  • The baseline is the dumbest sensible model. For a number (minutes) it is “always guess the mean” (or the median). For a yes/no (late) it is “always guess the commonest answer”, called the majority-class baseline. A model is only useful by how much it beats the baseline, never by its score alone.
  • The mean minimises the squared error; the median minimises the absolute error. So for MAE the median is always at least as good as the mean, and the difference tells you how skewed the data is.
  • Accuracy is the share of correct answers. If 85% of trips are on time, “always on time” scores 85% without learning anything, which is why accuracy alone can flatter a model. You will see this again in case 4.
  • In the lab, late is 1 when a trip was late and 0 when it was not, so df["late"].mean() is the late rate.

The lab gives you trips.csv and five blanks. All five answers are checked; when they are right it shows a report reference starting with GT{. Submit it at the bottom of the page.

Preparing your data…

🔒 The debrief unlocks when you close the case. Finish the lab above.

Write the answer for the vendor meeting

Write the short note Chidi takes into the vendor meeting: the baseline error of always guessing the mean and the median (and which is better), the accuracy of always guessing 'on time', what the vendor must show (a result against the baseline, on trips the model has not seen), and why a single score without a baseline means little.

0 words

🧪 Want to practise this on your own computer? See how to set up your lab →

📝

Knowledge Check

1 of 3

A model has a mean absolute error of 9 minutes. What else do you need before judging it?

Report a problem

About: /lessons/case-the-baseline