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_trueNDArray) –True y labels
-
(y_predNDArray) –Predicted y labels
-
(labelslist[str]) –Label names
-
(save_pathstr | None, default:None) –Path to save plot. Defaults to None.
-
(normalizeLiteral['true', 'pred', 'all'] | None, default:False) –Normalize. Defaults to False.
-
(max_colsint, 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_trueNDArray) –True y labels
-
(y_predNDArray) –Predicted y labels
-
(labelslist[str]) –Label names
-
(save_pathstr | 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_trueNDArray) –True y labels
-
(y_predNDArray) –Predicted y labels
-
(labelslist[str]) –Label names
-
(normalizeLiteral['true', 'pred', 'all'] | None, default:False) –Normalize. Defaults to False.
-
(save_pathPathLike | None, default:None) –Path to save plot. Defaults to None.
-
(titlestr | None, default:None) –Title. Defaults to None.
-
(widthint | None, default:None) –Width. Defaults to None.
-
(heightint | None, default:400) –Height. Defaults to 400.
-
(bg_colorstr, default:'rgba(38,42,50,1.0)') –Background color. Defaults to "rgba(38,42,50,1.0)".
Returns:
-
Figure–go.Figure: Plotly figure