Machine Learning

7 Common Machine Learning Mistakes

Comments

One ice cream sales forecast, seven ways it can go wrong: from wrong labels to reading correlation as cause. Each mistake gets one sketch and one check.

Seven sketches of machine learning mistakes, from closed days recorded as zero sales to ice cream and sunglasses sales driven by sunny days, next to the title 7 Common Machine Learning Mistakes
On this page

A store trains a model to forecast its daily ice cream sales. The data says that on some days, nobody bought a single cone.

The store was closed on those days. The model does not know that. It learns that some days have zero demand.

Many machine learning mistakes look like this. The code runs and the scores look fine, but the model learns the wrong lesson. In this post, I follow the same ice cream forecast through seven of them: wrong labels, overfitting, no baseline, tuning on the test set, shuffling time data, training-serving skew and reading correlation as cause. Each section shows the mistake in one sketch and ends with one check you can run on your own model.

The order follows the life of a model: the data, the training, the evaluation, production, and acting on the results. All numbers in the sketches are illustrative.

1. Wrong labels

Are the answers in your data right?

A model learns from its labels, so wrong labels teach wrong lessons. Here, days when the store was closed are recorded as 0 sales, as if nobody wanted ice cream.

Bar chart of cones sold per day over two weeks. Two days show 0 with a red cross and the label closed. The caption reads a zero that is not real demand

Two of the fourteen days are zeros because the store was closed, not because demand was zero.

This is not only a problem of small datasets. In Pervasive Label Errors in Test Sets Destabilize Machine Learning Benchmarks (opens in a new tab) (NeurIPS 2021), Northcutt, Athalye and Mueller estimate an average of at least 3.3% label errors in the test sets of 10 commonly used datasets.

2. Overfitting

Why does it fail on new days?

An overfit model memorizes noise in its training data. It scores well on that data and worse on new data. Here, a wiggly curve hits every past day and misses the new ones.

Sales plotted against temperature. A dashed zigzag line passes through every filled point, labeled overfit, hits every past day. A straight line labeled good fit runs through the middle. Hollow points for new days sit near the straight line. The caption reads perfect on the past, wrong on new days

The zigzag fits every past day. The new days, drawn hollow, follow the straight line instead.

3. No baseline

Is the model better than a simple rule?

Before you trust a model, score a simple rule. Here, “same as last week” is off by 12 cones a day and the model by 11. Is one cone worth a model?

Two horizontal bars for average error in cones per day. The rule same as last week has an error of 12, the model an error of 11, with the note only 1 cone better. The caption reads score a simple rule first

The model is only one cone a day better than the simple rule.

A model that wins by a small margin may still be worth it. The baseline tells you how small the margin is, so you can weigh it against the cost of building and running the model.

4. Test set tuning

Why did the score drop after launch?

Each time you check the test set and adjust, the model fits it a little more. Here, 50 tries raise the test score to 0.88, but new data gives 0.81.

A line rising from 0.80 to 0.88 over 50 tries on the test set. A separate red point after the line shows 0.81 on new data. The caption reads your choices fit the test set

The test score climbs with every adjustment. The score on new data does not.

5. Shuffled time data

Did the model see the future?

A random split mixes the days, so the model trains on days after the ones it is tested on. A real forecast never knows the future.

Two rows of daily boxes along a time arrow. In the random split, test days are scattered through the row, marked with a red cross. In the split by time, the last two days are the test days, marked with a green check. The caption reads train on the past, test on the future

A random split scatters the test days. A split by time keeps them at the end.

scikit-learn has a splitter for this. With two weeks of daily data in date order, TimeSeriesSplit always tests on days after the training days:

Split by timePython
import numpy as np
from sklearn.model_selection import TimeSeriesSplit

days = np.arange(14)  # two weeks of daily sales, in date order

for train, test in TimeSeriesSplit(n_splits=3, test_size=2).split(days):
    print("train", train.min(), "to", train.max(), "| test", test)
OutputText
train 0 to 7 | test [8 9]
train 0 to 9 | test [10 11]
train 0 to 11 | test [12 13]

Each round trains on the past and tests on the next two days, as the forecast will work after launch.

6. Training-serving skew

Why does live data look different?

A feature is computed one way in training and another way in production. Here, training used the measured temperature, but at 8 a.m. only the forecast exists.

Two inputs feed one model box. In training, the temperature measured at night is 31. Live at 8 a.m., only a forecast exists and the temperature is 27. A warning sign reads same name, new meaning. The caption reads build features the same way

The feature has the same name in both places, but it means something different.

The sketch shows one cause, a different data source. Different code paths for the same feature cause the same problem. Google’s Rules of Machine Learning (opens in a new tab) suggest two habits against it: save the features used at serving time and train on that log (rule 29), and reuse code between the training and serving pipelines (rule 32).

7. Correlation as cause

Will more sunglasses sell more ice cream?

A model finds patterns, not causes. Ice cream and sunglasses sell together because sunny days drive both. Pushing one will not move the other.

A sun labeled sunny day with arrows down to an ice cream cone and a pair of sunglasses, above boxes for ice cream sales and sunglasses sales. A dashed line between the two boxes is crossed out, labeled rise together, no cause. The caption reads look for what drives both

Sunny days drive both sales. The link between the two boxes is a pattern, not a cause.

Seven questions

Before you ship a model, ask the seven checks as questions, in the same order.

Data and training

  1. Are the labels right?
  2. Is the gap between training and validation small?
  3. Does it beat a simple baseline?

Testing and use

  1. Was the test set used only once?
  2. Is the split by time?
  3. Are features built the same way live?
  4. Is it a pattern or a cause?

Try this today

Pick one model you built. Answer the seven questions for it, and fix the first “no”.

Which of these mistakes have you seen most often? I would like to read your answer in the comments, with the number and a short story.

How to cite

If you use this code or tutorial in your work, articles or publications, please cite it.

Plain text
Mostapha Kalami Heris, 7 Common Machine Learning Mistakes (YPML302), Yarpiz, 2026. https://yarpiz.com/common-machine-learning-mistakes-ypml302
BibTeX
@misc{yarpiz-ypml302,
  author = {{Mostapha Kalami Heris}},
  title = {{7 Common Machine Learning Mistakes}},
  howpublished = {Yarpiz},
  year = {2026},
  note = {Code YPML302},
  url = {https://yarpiz.com/common-machine-learning-mistakes-ypml302}
}

Comments

Sign in or create a free account to join the discussion. No password needed.