# 7 Common Machine Learning Mistakes

URL: https://yarpiz.com/common-machine-learning-mistakes-ypml302
Author: Mostapha Kalami Heris
Published: 2026-12-03
Topics: Machine Learning

> 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.

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.

::: figure {src="https://yarpiz.com/media/2026/12/ml-mistakes-labels.jpg" alt="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" align="center"}
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](https://arxiv.org/abs/2103.14749) (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.

::: callout {type="tip" title="Check"}
Plot the labels, and read 50 random rows yourself.
:::

## 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.

::: figure {src="https://yarpiz.com/media/2026/12/ml-mistakes-overfitting.jpg" alt="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" align="center"}
The zigzag fits every past day. The new days, drawn hollow, follow the straight line instead.
:::

::: callout {type="tip" title="Check"}
Compare training and validation scores. A large gap is a warning.
:::

## 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?

::: figure {src="https://yarpiz.com/media/2026/12/ml-mistakes-baseline.jpg" alt="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" align="center"}
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.

::: callout {type="tip" title="Check"}
Report every score next to a baseline.
:::

## 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.

::: figure {src="https://yarpiz.com/media/2026/12/ml-mistakes-test-set.jpg" alt="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" align="center"}
The test score climbs with every adjustment. The score on new data does not.
:::

::: callout {type="tip" title="Check"}
Tune on a validation set. Use the test set once, at the end.
:::

## 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.

::: figure {src="https://yarpiz.com/media/2026/12/ml-mistakes-time-split.jpg" alt="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" align="center"}
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:

```python {title="Split by time"}
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)
```

```text {title="Output"}
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.

::: callout {type="tip" title="Check"}
Split by time: train on the past, test on later dates.
:::

## 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.

::: figure {src="https://yarpiz.com/media/2026/12/ml-mistakes-skew.jpg" alt="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" align="center"}
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](https://developers.google.com/machine-learning/guides/rules-of-ml) 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).

::: callout {type="tip" title="Check"}
Build features with the same code for training and serving.
:::

## 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.

::: figure {src="https://yarpiz.com/media/2026/12/ml-mistakes-correlation.jpg" alt="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" align="center"}
Sunny days drive both sales. The link between the two boxes is a pattern, not a cause.
:::

::: callout {type="tip" title="Check"}
Before you act on a feature, ask what else could cause both.
:::

## 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**

4. Was the test set used only once?
5. Is the split by time?
6. Are features built the same way live?
7. 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

Mostapha Kalami Heris, 7 Common Machine Learning Mistakes (YPML302), Yarpiz, 2026. https://yarpiz.com/common-machine-learning-mistakes-ypml302
