TATECHATLAS
◎ English
Math & models / Guide

How to use learning curves to decide if a model scales with data and whether to remove regularisation

A learning curve shows whether more data helps. A rising validation score with a narrowing gap means the model scales, so regularisation may be reduced. A flat validation score means the model is capacity-limited, so regularisation should stay or increase.

On this page

A learning curve compares training and validation scores across increasing training sizes. If the validation score rises and the gap between training and validation scores narrows as more data is added, the model is likely scaling with data, and reducing regularisation may help. If the validation score plateaus while the training score stays high, additional data will not fix the problem; the model is probably underfitting or limited by capacity, so regularisation should stay or increase. Always compute curves inside a Pipeline or fit preprocessing only on training folds to avoid optimistic bias.

1. Define the learning-curve experiment

A learning curve shows the training and validation score of an estimator for varying numbers of training samples. The goal is to see how much the model benefits from adding more training data and whether the error is dominated by bias or variance. The scikit-learn documentation defines the learning curve as a tool to check scalability of a predictive model. The experiment requires a fixed set of training sizes, a cross-validation strategy, and a scoring function such as accuracy for classifiers. The function learning_curve returns the number of samples used, the average training scores, and the average validation scores. The validation scores are computed on held-out folds, so the curve reflects generalisation rather than training fit. The example in the source uses SVC with a linear kernel on the Iris dataset and train_sizes [50, 80, 110] with cv=5. The exact numbers in the source are illustrative, but the procedure is the same for any tabular supervised problem. The key inputs are the estimator, the feature matrix, the target vector, the training sizes, the cross-validation splitter, and the scoring metric. The output is a set of curves that can be plotted to inspect the bias-variance trade-off and scalability.

from sklearn.datasets import load_iris
from sklearn.model_selection import learning_curve
from sklearn.svm import SVC
import numpy as np
X, y = load_iris(return_X_y=True)
train_sizes, train_scores, valid_scores = learning_curve(
    SVC(kernel='linear'), X, y, train_sizes=np.linspace(0.1, 1.0, 5), cv=5, random_state=0
)
print(train_sizes)
print(train_scores.mean(axis=1))
print(valid_scores.mean(axis=1))

Use a Pipeline for every estimator so that scaling, imputation, or feature selection is fitted only on training folds and applied to validation folds. This prevents data leakage and makes learning curves trustworthy before you change regularisation.

2. Interpret bias-variance from the curves

The bias-variance decomposition explains why the two curves behave differently. Bias is the average error of an estimator over different training sets, while variance is how sensitive the estimator is to varying training data. Noise is a property of the data. The scikit-learn source shows that a linear model with degree 1 polynomial features can only provide a poor fit because it is too simple, which is high bias. A model with degree 15 approximates the training data perfectly but does not fit the true function well, which is high variance. These tools, including validation curves and learning curves, make this visible in high-dimensional data where models are difficult to visualize. If both training and validation scores are low, the estimator is underfitting, which suggests high bias and possibly insufficient model capacity. If the training score is high and the validation score is low, the estimator is overfitting, which suggests high variance. If the training and validation scores are both high and close, the estimator is working well. The source states that if the training score and the validation score are both low, the estimator will be underfitting. If the training score is high and the validation score is low, the estimator is overfitting. Otherwise it is working very well. These interpretations are the basis for deciding whether more data or regularisation changes are needed.

from sklearn.datasets import load_iris
from sklearn.model_selection import validation_curve
from sklearn.svm import SVC
import numpy as np
X, y = load_iris(return_X_y=True)
train_scores, valid_scores = validation_curve(
    SVC(kernel='linear'), X, y, param_name='C', param_range=np.logspace(-7, 3, 3), cv=5
)
print(train_scores.mean(axis=1))
print(valid_scores.mean(axis=1))

3. Detect scalability: look for a narrowing gap

Scalability with data is detected by comparing the validation curve across training sizes. If the validation score rises as the training size increases and the gap between the training score and the validation score narrows, the model is likely benefiting from more data. The source explains that for small amounts of data, the training score of the SVM is much greater than the validation score, and adding more training samples will most likely increase generalization. This pattern indicates that the model has high variance at small sample sizes, and additional data reduces the variance. The narrowing gap is the key signal. It means the model is not simply memorising the training set and that the generalisation error is decreasing. The training score may remain high while the validation score climbs, which is a positive sign. The decision to collect more data or reduce regularisation is supported when the validation curve shows a clear upward trend and the gap narrows. The source states that adding more training samples will most likely increase generalization in this case. The upward trend must be consistent across the plotted sizes, not just a single point.

import matplotlib.pyplot as plt
plt.plot(train_sizes, train_scores.mean(axis=1), label='train')
plt.plot(train_sizes, valid_scores.mean(axis=1), label='valid')
plt.xlabel('Training size')
plt.ylabel('Score')
plt.legend()
plt.show()

4. Identify diminishing returns

Diminishing returns appear when the validation score plateaus while the training score remains high. In that case, adding more training data will not improve generalisation, and the model is likely underfitting or limited by capacity. The source explains that for the naive Bayes classifier, both the validation score and the training score converge to a value that is quite low with increasing size of the training set, so we will probably not benefit much from more training data. The same logic applies when the validation score is already high and flat while the training score stays high. The model has reached its achievable performance on the current data distribution and model family. The gap may be small, but the validation score is not rising, so the problem is not variance. The problem is bias or capacity. Removing regularisation would not help and could make the model worse by increasing variance. The decision should be to keep or increase regularisation, or to change the model architecture, add features, or reduce model complexity. The plateau must be observed over a range of training sizes, not a single flat point, before concluding that more data is useless.

import matplotlib.pyplot as plt
plt.plot(train_sizes, train_scores.mean(axis=1), label='train')
plt.plot(train_sizes, valid_scores.mean(axis=1), label='valid')
plt.axhline(y=0.95, color='gray', linestyle='--')
plt.text(train_sizes[-1], 0.95, 'target', color='gray')
plt.legend()
plt.show()

5. Decide on regularisation removal

The rule of thumb is to reduce regularisation only when the validation curve shows a clear upward trend and the gap between training and validation scores narrows as training size increases. In that case, the model is variance-limited at small sample sizes, and more data or weaker regularisation can improve generalisation. If the validation curve is flat, the model is likely underfitting or capacity-limited, so regularisation should stay or increase. The source states that another way to reduce the variance of a model is to use more training data, but you should only collect more training data if the true function is too complex to be approximated by an estimator with a lower variance. The same logic applies to regularisation: reducing regularisation is a variance-reduction strategy only when the curve indicates that variance is the dominant problem. If the validation score is already high and flat, reducing regularisation will likely increase variance without improving accuracy. The decision must be tied to the observed trend, not to a single validation score. The source also warns that if hyperparameters are optimised based on a validation score, the validation score is biased and not a good estimate of generalisation, so a separate test set is needed for the final decision.

from sklearn.pipeline import make_pipeline
from sklearn.preprocessing import StandardScaler
from sklearn.svm import SVC
model = make_pipeline(StandardScaler(), SVC(kernel='linear', C=1.0))

6. Avoid data leakage when computing curves

Data leakage occurs when information that would not be available at prediction time is used when building the model, resulting in overly optimistic performance estimates. A common cause is not keeping the test and train data subsets separate, or applying preprocessing to the whole dataset before splitting. The source states that the general rule is to never call fit on the test data. Although both train and test data subsets should receive the same preprocessing transformation, the transformations must be learned only from the training data. For example, if a normalization step divides by an average value, the average should be the average of the train subset, not the average of all the data. If the test subset is included in the average calculation, information from the test subset influences the model. The source recommends using a Pipeline to chain transformations with estimators, which ensures that the appropriate method is performed on the correct data subset. The pipeline is ideal for use in cross-validation and hyper-parameter tuning functions. When computing learning curves, every preprocessing step must be inside the Pipeline or fitted only on the training folds, otherwise the learning curve will be optimistically biased and the scalability conclusion will be invalid.

from sklearn.pipeline import make_pipeline
from sklearn.preprocessing import StandardScaler
from sklearn.svm import SVC
from sklearn.model_selection import cross_val_score
pipeline = make_pipeline(StandardScaler(), SVC(kernel='linear', C=1.0))
scores = cross_val_score(pipeline, X, y, cv=5)
print(scores.mean())

7. Use ValidationCurve for hyper-parameter tuning

A validation curve plots the training and validation score for a single hyperparameter, such as C in an SVM, across a range of values. It helps confirm whether the chosen regularisation value is appropriate as more data is added. The source shows that validation_curve can be used to find out whether the estimator is overfitting or underfitting for some hyperparameter values. The output is a matrix of training scores and a matrix of validation scores for each hyperparameter value and cross-validation fold. If the validation score is high and stable over a wide range of C values, the regularisation choice is robust. If the validation score drops sharply for small C, the model may be underfitting, and the regularisation may be too strong. If the validation score is high for small C but the training score is much higher, the model may be overfitting, and the regularisation may be too weak. The validation curve is a diagnostic tool for the current data size. It does not replace the learning curve, but it complements it by showing how the model responds to the regularisation parameter. When more data is added, the optimal C may shift, so the validation curve should be re-run with the new training size or with the full dataset if the goal is final tuning.

from sklearn.datasets import load_iris
from sklearn.model_selection import ValidationCurveDisplay
from sklearn.svm import SVC
from sklearn.utils import shuffle
import numpy as np
X, y = load_iris(return_X_y=True)
X, y = shuffle(X, y, random_state=0)
ValidationCurveDisplay.from_estimator(
    SVC(kernel='linear'), X, y, param_name='C', param_range=np.logspace(-7, 3, 10)
)

8. Document the decision and monitor in production

The decision about regularisation and data collection should be documented with the learning-curve plots, the chosen regularisation level, and the evaluation protocol. A good practice is to record the learning-curve plots, the chosen regularisation level, and the evaluation protocol, and to set up monitoring if the data distribution may change over time. The documentation should include the training sizes, the metric, the cross-validation strategy, the random_state, and the preprocessing steps. The decision rule is based on the trend of the validation curve and the gap between training and validation scores. If the validation score rises and the gap narrows, the model benefits from more data and regularisation may be reduced. If the validation score plateaus while the training score remains high, additional data will not help, and regularisation should stay or increase. In production, the data distribution may drift, so the learning curve should be recomputed periodically. The monitoring pipeline should detect changes in the validation score, the gap, and the data distribution. The decision is not a one-time event; it must be revisited as new data arrives and as the model is retrained.

import json
gap_trend = 'narrowing' if valid_scores.mean(axis=1)[-1] > valid_scores.mean(axis=1)[0] else 'flat'
decision = {
    'train_sizes': train_sizes.tolist(),
    'train_mean': train_scores.mean(axis=1).tolist(),
    'valid_mean': valid_scores.mean(axis=1).tolist(),
    'gap_trend': gap_trend,
    'regularisation_action': 'reduce' if gap_trend == 'narrowing' else 'keep_or_increase'
}
print(json.dumps(decision, indent=2))

Things to check

  • Learning curves must use a fixed train/validation split or cross-validation so that validation scores are comparable across training sizes.
  • Preprocessing steps must be fitted only on training folds and applied to validation folds, otherwise the curve is optimistically biased.
  • A narrowing gap with rising validation score indicates variance reduction from more data, not necessarily a better model.
  • A flat validation curve with a high training score indicates bias or capacity limits, so removing regularisation is not justified.
  • Regularisation decisions should be based on the observed curve trend, not on a single validation score.
  • The learning-curve experiment must use a fixed random_state for reproducibility and consistent data ordering.
  • The validation score used for the decision must be computed on data not seen during preprocessing or hyperparameter selection.
  • The conclusion about scalability must be stated as a trend over training sizes, not as a guarantee for unseen data.
  • If the validation score is noisy, use more training sizes or repeated cross-validation before changing regularisation.
  • The decision to reduce regularisation should be recorded with the plot, the parameter value, and the evaluation protocol.

This guide assumes tabular supervised learning with a clear train/test split and fixed random_state. It does not cover unsupervised learning, time-series cross-validation, or scenarios where the validation distribution changes over time. The conclusion is probabilistic and depends on the chosen metric, model family, and data quality.

Sources

  1. scikit-learn: learning curves ↗
  2. scikit-learn: common pitfalls ↗
Back to top ↑