confusion_matrix#
- ComparisonReport.metrics.confusion_matrix(*, data_source='test')[source]#
Plot the confusion matrix.
The confusion matrix shows the counts of correct and incorrect classifications for each class.
- Parameters:
- data_source{“test”, “train”}, default=”test”
The data source to use.
“test” : use the test set provided when creating the report.
“train” : use the train set provided when creating the report.
- Returns:
ConfusionMatrixDisplayThe confusion matrix display.
See also
ConfusionMatrixDisplayDisplay class for confusion matrix plots.
Notes
To keep the stored display lightweight, the thresholded confusion matrices are downsampled to at most 500 points per class and per child report. Sampling is performed by picking evenly-spaced indices on the sorted thresholds.
Examples
>>> from sklearn.datasets import load_breast_cancer >>> from sklearn.linear_model import LogisticRegression >>> from sklearn.svm import SVC >>> from skore import evaluate >>> X, y = load_breast_cancer(return_X_y=True) >>> comparison = evaluate( ... [LogisticRegression(max_iter=10_000), SVC()], ... X, ... y, ... splitter=2, ... pos_label=1, ... ) >>> display = comparison.metrics.confusion_matrix() >>> display.plot()