Learning Curve visualization.
It is recommended to use from_estimator to create a LearningCurveDisplay instance. All parameters are stored as attributes.
Read more in the User Guide for general information about the visualization API and detailed documentation regarding the learning curve visualization.
Added in version 1.2.
Numbers of training examples that has been used to generate the learning curve.
Scores on training sets.
Scores on test set.
The name of the score used in learning_curve. It will override the name inferred from the scoring parameter. If score is None, we use "Score" if negate_score is False and "Negative score" otherwise. If scoring is a string or a callable, we infer the name. We replace _ by spaces and capitalize the first letter. We remove neg_ and replace it by "Negative" if negate_score is False or just remove it otherwise.
Axes with the learning curve.
Figure containing the learning curve.
When the std_display_style is "errorbar", this is a list of matplotlib.container.ErrorbarContainer objects. If another style is used, errorbar_ is None.
When the std_display_style is "fill_between", this is a list of matplotlib.lines.Line2D objects corresponding to the mean train and test scores. If another style is used, line_ is None.
When the std_display_style is "fill_between", this is a list of matplotlib.collections.PolyCollection objects. If another style is used, fill_between_ is None.
See also
sklearn.model_selection.learning_curveCompute the learning curve.
>>> import matplotlib.pyplot as plt >>> from sklearn.datasets import load_iris >>> from sklearn.model_selection import LearningCurveDisplay, learning_curve >>> from sklearn.tree import DecisionTreeClassifier >>> X, y = load_iris(return_X_y=True) >>> tree = DecisionTreeClassifier(random_state=0) >>> train_sizes, train_scores, test_scores = learning_curve( ... tree, X, y) >>> display = LearningCurveDisplay(train_sizes=train_sizes, ... train_scores=train_scores, test_scores=test_scores, score_name="Score") >>> display.plot() <...> >>> plt.show()
Create a learning curve display from an estimator.
Read more in the User Guide for general information about the visualization API and detailed documentation regarding the learning curve visualization.
An object of that type which is cloned for each validation.
Training data, where n_samples is the number of samples and n_features is the number of features.
Target relative to X for classification or regression; None for unsupervised learning.
Group labels for the samples used while splitting the dataset into train/test set. Only used in conjunction with a “Group” cv instance (e.g., GroupKFold).
Relative or absolute numbers of training examples that will be used to generate the learning curve. If the dtype is float, it is regarded as a fraction of the maximum size of the training set (that is determined by the selected validation method), i.e. it has to be within (0, 1]. Otherwise it is interpreted as absolute sizes of the training sets. Note that for classification the number of samples usually have to be big enough to contain at least one sample from each class.
Determines the cross-validation splitting strategy. Possible inputs for cv are:
(Stratified)KFold,For int/None inputs, if the estimator is a classifier and y is either binary or multiclass, StratifiedKFold is used. In all other cases, KFold is used. These splitters are instantiated with shuffle=False so the splits will be the same across calls.
Refer User Guide for the various cross-validation strategies that can be used here.
A string (see The scoring parameter: defining model evaluation rules) or a scorer callable object / function with signature scorer(estimator, X, y) (see Callable scorers).
If the estimator supports incremental learning, this will be used to speed up fitting for different training set sizes.
Number of jobs to run in parallel. Training the estimator and computing the score are parallelized over the different training and test sets. None means 1 unless in a joblib.parallel_backend context. -1 means using all processors. See Glossary for more details.
Number of predispatched jobs for parallel execution (default is all). The option can reduce the allocated memory. The str can be an expression like ‘2*n_jobs’.
Controls the verbosity: the higher, the more messages.
Whether to shuffle training data before taking prefixes of it based on`train_sizes`.
Used when shuffle is True. Pass an int for reproducible output across multiple function calls. See Glossary.
Value to assign to the score if an error occurs in estimator fitting. If set to ‘raise’, the error is raised. If a numeric value is given, FitFailedWarning is raised.
Parameters to pass to the fit method of the estimator.
Axes object to plot on. If None, a new figure and axes is created.
Whether or not to negate the scores obtained through learning_curve. This is particularly useful when using the error denoted by neg_* in scikit-learn.
The name of the score used to decorate the y-axis of the plot. It will override the name inferred from the scoring parameter. If score is None, we use "Score" if negate_score is False and "Negative score" otherwise. If scoring is a string or a callable, we infer the name. We replace _ by spaces and capitalize the first letter. We remove neg_ and replace it by "Negative" if negate_score is False or just remove it otherwise.
The type of score to plot. Can be one of "test", "train", or "both".
The style used to display the score standard deviation around the mean score. If None, no representation of the standard deviation is displayed.
Additional keyword arguments passed to the plt.plot used to draw the mean score.
Additional keyword arguments passed to the plt.fill_between used to draw the score standard deviation.
Additional keyword arguments passed to the plt.errorbar used to draw mean score and standard deviation score.
LearningCurveDisplay
Object that stores computed values.
>>> import matplotlib.pyplot as plt >>> from sklearn.datasets import load_iris >>> from sklearn.model_selection import LearningCurveDisplay >>> from sklearn.tree import DecisionTreeClassifier >>> X, y = load_iris(return_X_y=True) >>> tree = DecisionTreeClassifier(random_state=0) >>> LearningCurveDisplay.from_estimator(tree, X, y) <...> >>> plt.show()
Plot visualization.
Axes object to plot on. If None, a new figure and axes is created.
Whether or not to negate the scores obtained through learning_curve. This is particularly useful when using the error denoted by neg_* in scikit-learn.
The name of the score used to decorate the y-axis of the plot. It will override the name inferred from the scoring parameter. If score is None, we use "Score" if negate_score is False and "Negative score" otherwise. If scoring is a string or a callable, we infer the name. We replace _ by spaces and capitalize the first letter. We remove neg_ and replace it by "Negative" if negate_score is False or just remove it otherwise.
The type of score to plot. Can be one of "test", "train", or "both".
The style used to display the score standard deviation around the mean score. If None, no standard deviation representation is displayed.
Additional keyword arguments passed to the plt.plot used to draw the mean score.
Additional keyword arguments passed to the plt.fill_between used to draw the score standard deviation.
Additional keyword arguments passed to the plt.errorbar used to draw mean score and standard deviation score.
LearningCurveDisplay
Object that stores computed values.
© 2007–2025 The scikit-learn developers
Licensed under the 3-clause BSD License.
https://scikit-learn.org/1.6/modules/generated/sklearn.model_selection.LearningCurveDisplay.html