Signature
LearningCurveDisplay.from_estimator(estimator, X, y, cv=5)What it does
LearningCurveDisplay runs cross-validation at increasing training sizes and plots both curves. A large persistent gap suggests variance, while both curves converging low suggests the model is too simple.
Parameters
estimatorestimator- Model to evaluate; it is refit at each training size.
Xarray-like- Feature matrix.
yarray-like- Target labels or values.
cvint or splitter, optionaloptional- Cross-validation strategy.
Returns
LearningCurveDisplay
Example
pythonLearningCurveDisplay example
import matplotlib.pyplot as plt
from sklearn.model_selection import LearningCurveDisplay
from sklearn.ensemble import RandomForestClassifier
LearningCurveDisplay.from_estimator(RandomForestClassifier(), X, y, cv=5)
plt.show()Watch out for
- The full curve is expensive; start with a smaller number of training sizes.
- Training and validation axes can use different scoring scales; check the labels.