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")