DOC Adds 'scoring' to plot_learning_curve example
@@ -35,6 +35,7 @@ def plot_learning_curve(
ylim=None,
cv=None,
n_jobs=None,
+ scoring=None,
train_sizes=np.linspace(0.1, 1.0, 5),
):
"""
@@ -86,6 +87,11 @@ def plot_learning_curve(
``-1`` means using all processors. See :term:`Glossary <n_jobs>`
for more details.
+ scoring : str or callable, default=None
+ A str (see model evaluation documentation) or
+ a scorer callable object / function with signature
+ ``scorer(estimator, X, y)``.
+
train_sizes : array-like of shape (n_ticks,)
Relative or absolute numbers of training examples that will be used to
generate the learning curve. If the ``dtype`` is float, it is regarded
@@ -109,6 +115,7 @@ def plot_learning_curve(
estimator,
X,
y,
+ scoring=scoring,
cv=cv,
n_jobs=n_jobs,
train_sizes=train_sizes,
@@ -189,7 +196,15 @@ cv = ShuffleSplit(n_splits=50, test_size=0.2, random_state=0)
estimator = GaussianNB()
plot_learning_curve(
- estimator, title, X, y, axes=axes[:, 0], ylim=(0.7, 1.01), cv=cv, n_jobs=4
+ estimator,
+ title,
+ X,
+ y,
+ axes=axes[:, 0],
+ ylim=(0.7, 1.01),
+ cv=cv,
+ n_jobs=4,
+ scoring="accuracy",
)
title = r"Learning Curves (SVM, RBF kernel, $\gamma=0.001$)"
