ConfusionMatrixDisplay#
- class skore.ConfusionMatrixDisplay(*, confusion_matrix, display_labels, report_type)[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”, and “normalized_by_all”. Each row represents one cell of the 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.
- Attributes:
- figure_matplotlib Figure
Figure containing the confusion matrix.
- ax_matplotlib Axes
Axes with confusion matrix.
- frame(normalize=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.
- Returns:
- framepandas.DataFrame
The confusion matrix as a dataframe in pivot format with true labels as rows and predicted labels as columns. Values are counts or normalized values depending on the
normalizeparameter.
- plot(*, normalize=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.
- 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