cm
Confusion Matrix Plotting API
This module provides utility functions to plot confusion matrices.
Functions:
-
multilabel_confusion_matrix_plot
–Generate multilabel confusion matrix plot via matplotlib/seaborn
-
confusion_matrix_plot
–Generate confusion matrix plot via matplotlib/seaborn
-
px_plot_confusion_matrix
–Generate confusion matrix plot via plotly
Functions
multilabel_confusion_matrix_plot
multilabel_confusion_matrix_plot(y_true: npt.NDArray, y_pred: npt.NDArray, labels: list[str], save_path: os.PathLike | None = None, normalize: Literal['true', 'pred', 'all'] | None = False, max_cols: int = 5, **kwargs) -> tuple[plt.Figure, plt.Axes] | None
Generate multilabel confusion matrix plot via matplotlib/seaborn
Parameters:
-
y_true
(NDArray
) –True y labels
-
y_pred
(NDArray
) –Predicted y labels
-
labels
(list[str]
) –Label names
-
save_path
(str | None
, default:None
) –Path to save plot. Defaults to None.
-
normalize
(Literal['true', 'pred', 'all'] | None
, default:False
) –Normalize. Defaults to False.
-
max_cols
(int
, default:5
) –Max columns. Defaults to 5.
Returns:
-
tuple[Figure, Axes] | None
–tuple[plt.Figure, plt.Axes] | None: Figure and axes
Source code in neuralspot_edge/plotting/cm.py
confusion_matrix_plot
confusion_matrix_plot(y_true: npt.NDArray, y_pred: npt.NDArray, labels: list[str], save_path: os.PathLike | None = None, normalize: Literal['true', 'pred', 'all'] | None = False, **kwargs) -> tuple[plt.Figure, plt.Axes] | None
Generate confusion matrix plot via matplotlib/seaborn
Parameters:
-
y_true
(NDArray
) –True y labels
-
y_pred
(NDArray
) –Predicted y labels
-
labels
(list[str]
) –Label names
-
save_path
(str | None
, default:None
) –Path to save plot. Defaults to None.
Returns:
-
tuple[Figure, Axes] | None
–tuple[plt.Figure, plt.Axes] | None: Figure and axes
Source code in neuralspot_edge/plotting/cm.py
px_plot_confusion_matrix
px_plot_confusion_matrix(y_true: npt.NDArray, y_pred: npt.NDArray, labels: list[str], normalize: Literal['true', 'pred', 'all'] | None = False, save_path: os.PathLike | None = None, title: str | None = None, width: int | None = None, height: int | None = 400, bg_color: str = 'rgba(38,42,50,1.0)') -> go.Figure
Generate confusion matrix plot via plotly
Parameters:
-
y_true
(NDArray
) –True y labels
-
y_pred
(NDArray
) –Predicted y labels
-
labels
(list[str]
) –Label names
-
normalize
(Literal['true', 'pred', 'all'] | None
, default:False
) –Normalize. Defaults to False.
-
save_path
(PathLike | None
, default:None
) –Path to save plot. Defaults to None.
-
title
(str | None
, default:None
) –Title. Defaults to None.
-
width
(int | None
, default:None
) –Width. Defaults to None.
-
height
(int | None
, default:400
) –Height. Defaults to 400.
-
bg_color
(str
, default:'rgba(38,42,50,1.0)'
) –Background color. Defaults to "rgba(38,42,50,1.0)".
Returns:
-
Figure
–go.Figure: Plotly figure