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.
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,
lateis 1 when a trip was late and 0 when it was not, sodf["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…
Ngozi: “The vendor’s 9 minutes might be measured on the data their model already saw. How would you make them prove it, and what number would you ask them to give you instead?”
🔒 The debrief unlocks when you close the case. Finish the lab above.
The debrief
Chidi: “So the thing to beat is about this many minutes, and ‘always on time’ is right most of the time anyway. I will ask them to show me better than that, on trips they have not seen.”
What a senior practitioner would do next. Make the baseline the first line of every project, and report every result as “X, against a baseline of Y”. A fancy model that beats the baseline by 2% may not be worth its running cost, while a simple rule that beats it by 40% is a result. The baseline also tells you the ceiling of effort: if the baseline is already close to perfect, stop.
The traps. Reporting accuracy on an imbalanced problem (always guessing the majority looks excellent); comparing a model’s error with nothing at all; and forgetting that the baseline must be computed from the same data and in the same way as the model’s score.
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.
🧪 Want to practise this on your own computer? See how to set up your lab →