coco_pipe.viz.plot_confusion_matrix#

coco_pipe.viz.plot_confusion_matrix(result_or_matrix, model=None, fold=None, title=None, ax=None, figsize=None)#

Plot an aggregated confusion matrix from decoding diagnostics.

Parameters:
  • result_or_matrix (Any) – Experiment result with get_confusion_matrices() or a tidy confusion matrix DataFrame containing TrueLabel, PredictedLabel, and Value.

  • model (str | None) – Optional model name used to filter rows before aggregation.

  • fold (int | None) – Optional fold index used to filter rows before aggregation.

  • title (str | None) – Optional axes title. Defaults to "Confusion Matrix".

  • ax (Axes | None) – Existing Matplotlib axes to draw into.

  • figsize (tuple[float, float] | None) – Figure size used when ax is not provided.

Returns:

The created or reused figure and axes.

Return type:

tuple[matplotlib.figure.Figure, matplotlib.axes.Axes]

See also

coco_pipe.viz.interactive.decoding.plot_confusion_matrix

Interactive Plotly version.

plot_roc_curve

Receiver-operating-characteristic curve.

plot_probability_diagnostics

Probability-calibration quality metrics.

plot_decoding_scores

Aggregate scalar score summary.

Examples

>>> import pandas as pd
>>> from coco_pipe.viz import decoding as viz
>>> df = pd.DataFrame(
...     {
...         "TrueLabel": list("AABB"),
...         "PredictedLabel": list("ABAB"),
...         "Value": [5, 1, 2, 4],
...     }
... )
>>> fig, ax = viz.plot_confusion_matrix(df)

Examples using coco_pipe.viz.plot_confusion_matrix#

Basic Decoding: Classification and Model Verification

Basic Decoding: Classification and Model Verification