Foundations

Estimating Whether You Have Enough Data to Train a Model

Judge whether your dataset is big enough using learning curves, worked extrapolations and the size of the uncertainty in your test score.

Key takeaways

  • Define the target performance first, because the data requirement depends on how good the model must be.
  • A learning curve on your own data is far more informative than a general rule of thumb.
  • For rare outcomes, the number of positive examples usually matters more than the total number of rows.
  • The test set needs its own size calculation, since a small one cannot confirm a small improvement.
  • More data of the same biased kind does not repair missing populations, bad labels or uninformative features.

No formula gives the number of examples a project needs before you look at the data. You can, however, measure it: train on increasing fractions of what you have, see how validation error falls, and ask whether the curve is still dropping. Separately, check that your test set is large enough to tell a good model from a mediocre one.

"Enough" always means enough for a stated goal. A rough prototype may need a few hundred examples, while certifying a very low error rate on rare cases can need vastly more.

Define "enough" before measuring

Write down the result that would let you ship. It might be recall of at least 80 percent at a false alarm rate your team can handle, or an average forecasting error smaller than the current method's by some margin. Add the slices that must meet it.

This target turns a vague worry into a testable gap. If you are at 71 percent recall and need 80, you can ask how the curve has moved as data grew. If the current method is already matched with a tenth of your records, you may have plenty. A target also prevents endless collection: once it is met with a comfortable interval, further labeling needs a new justification.

Check, too, that the target is possible. If two experts reading the same inputs agree only 85 percent of the time, asking a model to score 95 percent against either of them is asking for something the labels cannot express. Better labels, or an adjudication step for disagreements, would then matter more than more rows.

What determines the requirement

Several factors push the number up or down.

Factor Needs more data when
Signal Inputs predict the target only weakly
Model flexibility The model has many effective degrees of freedom
Input complexity There are many features, categories or raw pixels
Class balance The event of interest is rare
Label quality Labels are noisy or inconsistent
Variety Many subpopulations or conditions must all work
Starting point You train from scratch instead of adapting a pretrained model

Old rules of thumb, such as a minimum number of outcome events per coefficient in logistic regression, are rough screens whose adequacy is debated. Treat them as a warning light. Theoretical sample complexity bounds explain how requirements grow, but they are usually far too pessimistic to plan a project.

Start with a learning curve

Fix a validation set. Train on 10, 20, 40, 70 and 100 percent of your training data, repeating the smaller sizes with different random subsets. Plot training and validation error against the number of examples.

If validation error is still falling clearly at 100 percent, more data of the same kind will probably help. If it has flattened and sits close to training error, the current features and model have little left to gain from volume. Reading learning curves explains the other shapes.

Use a logarithmic axis for the number of examples. Gains usually come with multiples, so the step from 1,000 to 2,000 is comparable to the step from 10,000 to 20,000.

Interpreting the repeats matters as much as the averages. At small sizes, different random subsets can give very different scores. If the spread among runs at 20 percent of the data is as large as the gain you see from 40 to 100 percent, you cannot yet tell whether the curve is rising. Cross-validation, which rotates the held-out portion, gives a steadier curve when data is scarce.

Respect the structure of your data while subsampling. If rows come in groups, such as visits per patient, add whole groups at each step. Adding more rows from the same few people looks like growth and teaches little. If the data is ordered in time, grow the training window backward from a fixed validation period, which also shows whether older records still help.

Extrapolating with care

Over a modest range, error is often described reasonably by a floor plus a term that shrinks as a power of n. A simple version is error(n) = a + b/√n. The exponent 0.5 is an assumption, and fitting it from your own points is better when you have several.

Suppose, in an invented example, validation error is 0.20 with 1,000 examples and 0.15 with 4,000.

1/√1000 ≈ 0.03162,   1/√4000 ≈ 0.01581
b = (0.20 − 0.15) / (0.03162 − 0.01581) ≈ 3.162
a = 0.20 − 3.162 × 0.03162 ≈ 0.10
at n = 16,000:   0.10 + 3.162 × 0.00791 ≈ 0.125
for error 0.11:  3.162 / √n = 0.01  →  n ≈ 100,000

Going from 4,000 to 16,000 buys 2.5 points. The next 1.5 points need about six times more again. And under this fit, no amount of data gets below 0.10.

Example: error predicted by a fitted square-root curve
1,000 examples 20% error 4,000 examples 15% error 16,000 examples 12.5% error 100,000 examples 11% error 1,000 examples 20% error 4,000 examples 15% error 16,000 examples 12.5% error 100,000 examples 11% error

Hypothetical example: the numbers are made up to show the method, not a quote or an average.

Two points always fit a two-parameter curve exactly, so this example cannot test itself. Real forecasts need more sizes, repeated runs and a healthy distrust of predictions far beyond the observed range.

Count the rare events

If you have 100,000 transactions of which 50 are fraud, you effectively have a small dataset for learning what fraud looks like. Extra legitimate transactions help to describe normal behavior but add little about the rare class.

Count positives in each split. With 50 in total and a 20 percent test set, you would test on about 10 fraud cases. Catching one more or fewer changes recall by 10 points.

The same applies to subgroups. A model may be well served overall and starved for a region, device type or age band that appears a few dozen times. List the slices you must perform well on and count their examples. Handling imbalance helps training, but resampling cannot create new information.

Size the test set separately

A measured accuracy is an estimate. For n independent test examples and true accuracy p, an approximate 95 percent interval is p ± 1.96 × √(p(1 − p)/n). With p = 0.9:

Test examples Approximate half-width
100 ±5.9 points
1,000 ±1.9 points
10,000 ±0.6 points

To reach ±2 points, solve 1.96 × √(0.09/n) = 0.02, which gives n ≈ 865. Halving the width requires about four times the examples.

The approximation is poor when errors are very few. If a model makes no errors on n independent examples, a handy 95 percent upper bound on its error rate is about 3/n. Zero errors in 300 trials supports a claim of under about 1 percent, and no stronger. See intervals for test metrics. Correlated examples, such as many images from one patient, count for much less than their number suggests.

Check that quantity is the problem

Before funding more collection, rule out other limits.

  • Training error is high too. The model or features may be too weak.
  • Labels disagree. Have two people label the same sample; frequent disagreement sets a floor on what you can measure and learn.
  • A population is missing. More rows from the same source will not add it.
  • The signal is absent. If no one, given these inputs, could guess better than the base rate, add informative variables.
  • The world has changed. Years of old records may be less useful than a few recent months.

A quick test is to double the data from an existing archive, if you have one, and see whether the curve moves as predicted.

Ways to need less

When collection is expensive, change the problem. Adapt a pretrained model for text, images or audio. Use a simpler model with sensible constraints. Engineer a few features that express what experts already know. Create label-preserving variations through augmentation. Borrow strength across related groups.

You can also spend the labeling budget more wisely with active learning or use unlabeled records through semi-supervised methods. Keep the test set randomly sampled from the real population, because actively chosen examples do not represent it.

A pilot when you have nothing yet

Sometimes the question arrives before any data does. Collect a small pilot, say a few hundred cases sampled the way the real system will receive them. Label them carefully and note how long each label takes.

The pilot answers several things at once: how common each class is, how often labelers disagree, which inputs are frequently missing and whether any signal shows up with a simple model. It also gives a cost per example, which turns a data estimate into a budget. Published work on similar problems can suggest a starting order of magnitude, but your inputs, labels and population differ, so treat it as a guess to be replaced by your own curve.

Reporting your estimate

Give decision makers a range and the evidence for it. State the target metric, the current value with its interval, the learning curve, the fitted extrapolation and its assumptions, and the count of rare cases. Recommend a next batch of a specific size, with a prediction you will check.

For instance: "Doubling labeled records should reduce error by about one to two points. We will re-estimate after the first 2,000 and stop if the gain is under half a point." Collecting in stages like this limits the cost of being wrong.

Written for 4MachineLearning with AI writing tools and not reviewed line by line by a person. Check anything you rely on against a textbook or primary source. Report an error.

Keep reading

All 42 articles in Foundations →

Latest news on this topic