ConfusionMatrixDisplay#
- class skore.ConfusionMatrixDisplay(*, confusion_matrix, display_labels, report_type, threshold=False)[source]#
Display for confusion matrix.
- Parameters:
- confusion_matrixpd.DataFrame
Confusion matrix data in long format with columns: “True label”, “Predicted label”, “count”, “normalized_by_true”, “normalized_by_pred”, “normalized_by_all” and “threshold”. Each row represents one cell of one confusion matrix.
- display_labelslist of str
Display labels for plot axes.
- report_type{“comparison-cross-validation”, “comparison-estimator”, “cross-validation”, “estimator”}
The type of report.
- thresholdbool, default=False
Whether threshold support is enabled for binary classification.
- Attributes:
- thresholds_list of float or None
Thresholds of the decision function. Each threshold is associated with a confusion matrix. Only available for binary classification with decision scores.
- figure_matplotlib Figure
Figure containing the confusion matrix.
- ax_matplotlib Axes
Axes with confusion matrix.
- frame(normalize=None, threshold_value=None)[source]#
Return the confusion matrix as a dataframe.
- Parameters:
- normalize{‘true’, ‘pred’, ‘all’}, default=None
Normalizes confusion matrix over the true (rows), predicted (columns) conditions or all the population. If None, the confusion matrix will not be normalized.
- threshold_valuefloat or ‘all’ or None, default=None
The decision threshold to use when applicable. If None and thresholds are available, returns the confusion matrix at the default threshold (0.5). If ‘all’, returns all flattened confusion matrices (one per threshold) as a single dataframe.
- Returns:
- framepandas.DataFrame
The confusion matrix as a dataframe.
- plot(*, normalize=None, threshold_value=None, heatmap_kwargs=None)[source]#
Plot visualization.
- Parameters:
- normalize{‘true’, ‘pred’, ‘all’}, default=None
Normalizes confusion matrix over the true (rows), predicted (columns) conditions or all the population. If None, the confusion matrix will not be normalized.
- threshold_valuefloat or None, default=None
The decision threshold to use when applicable. If None and thresholds are available, plots the confusion matrix at the default threshold (0.5).
- heatmap_kwargsdict, default=None
Additional keyword arguments to be passed to seaborn’s
sns.heatmap.
- Returns:
- selfConfusionMatrixDisplay
Configured with the confusion matrix.
- set_style(*, policy='override', **kwargs)[source]#
Set the style parameters for the display.
- Parameters:
- policyLiteral[“override”, “update”], default=”override”
Policy to use when setting the style parameters. If “override”, existing settings are set to the provided values. If “update”, existing settings are not changed; only settings that were previously unset are changed.
- **kwargsdict
Style parameters to set. Each parameter name should correspond to a a style attribute passed to the plot method of the display.
- Returns:
- selfobject
Returns the instance itself.
- Raises:
- ValueError
If a style parameter is unknown.
- static style_plot(plot_func)[source]#
Apply consistent style to skore displays.
This decorator: 1. Applies default style settings 2. Executes
plot_func3. Callsplt.tight_layout()to make sure axis does not overlap 4. Restores the original style settings- Parameters:
- plot_funccallable
The plot function to be decorated.
- Returns:
- callable
The decorated plot function.
Gallery examples#
EstimatorReport: Get insights from any scikit-learn estimator