From 636e54a6c8d2efe992bc033b2e4ddd9de09c898b Mon Sep 17 00:00:00 2001 From: talgatomarov <37542479+talgatomarov@users.noreply.github.com> Date: Tue, 4 Feb 2020 15:54:04 +0600 Subject: [PATCH] DOC Added example for plot_confusion_matrix (#16361) --- sklearn/metrics/_plot/confusion_matrix.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/sklearn/metrics/_plot/confusion_matrix.py b/sklearn/metrics/_plot/confusion_matrix.py index 537d2b9f0d8..df4e59fb538 100644 --- a/sklearn/metrics/_plot/confusion_matrix.py +++ b/sklearn/metrics/_plot/confusion_matrix.py @@ -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")