DOC Added example for plot_confusion_matrix (#16361)

This commit is contained in:
talgatomarov 2020-02-04 15:54:04 +06:00 committed by GitHub
parent daec09e6b4
commit 636e54a6c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 0 deletions

View File

@ -176,6 +176,22 @@ def plot_confusion_matrix(estimator, X, y_true, labels=None,
Returns
-------
display : :class:`~sklearn.metrics.ConfusionMatrixDisplay`
Examples
--------
>>> import matplotlib.pyplot as plt # doctest: +SKIP
>>> from sklearn.datasets import make_classification
>>> from sklearn.metrics import plot_confusion_matrix
>>> from sklearn.model_selection import train_test_split
>>> from sklearn.svm import SVC
>>> X, y = make_classification(random_state=0)
>>> X_train, X_test, y_train, y_test = train_test_split(
... X, y, random_state=0)
>>> clf = SVC(random_state=0)
>>> clf.fit(X_train, y_train)
SVC(random_state=0)
>>> plot_confusion_matrix(clf, X_test, y_test) # doctest: +SKIP
>>> plt.show() # doctest: +SKIP
"""
check_matplotlib_support("plot_confusion_matrix")