scanpex.pl.ml_evaluation package

Module contents

scanpex.pl.ml_evaluation.multiclass_pr(model, x, y, ax, cmap, label_dict, minimalist=False)[source]

Plot One-vs-Rest Precision-Recall curves and the micro-average curve.

This function visualizes the trade-off between Precision and Recall. It plots: 1. Individual curves for each class. 2. A “micro-average” curve calculated by aggregating all class predictions. 3. Baseline lines representing the prevalence of each class. 4. An optional “ideal” line (Precision=1.0).

Parameters:
  • model (object) – The trained classification model.

  • x (np.ndarray) – The input features.

  • y (np.ndarray) – The ground truth labels (one-hot encoded).

  • ax (matplotlib.axes.Axes) – The axis on which to draw the plot.

  • cmap (str or list) – The color mapping strategy. - If str: Name of a matplotlib colormap. - If list: Specific colors for each class.

  • label_dict (list of str) – The names of the classes corresponding to the columns of y.

  • minimalist (bool, optional) – If True, hides the “ideal” line (perfect precision) to reduce clutter. By default False.

Returns:

The plot is drawn directly onto the provided ax object.

Return type:

None

scanpex.pl.ml_evaluation.multiclass_roc(model, x, y, ax, cmap, label_dict, minimalist=False)[source]

Plot One-vs-Rest ROC curves and the macro-average curve.

This function visualizes the performance of a multi-class classifier by plotting individual ROC curves for each class and an interpolated macro-average curve. It also displays the baseline (random guess) and optionally the ideal curve.

Parameters:
  • model (object) – The trained classification model.

  • x (np.ndarray) – The input features.

  • y (np.ndarray) – The ground truth labels (one-hot encoded).

  • ax (matplotlib.axes.Axes) – The axis on which to draw the plot.

  • cmap (str or list) – The color mapping strategy. - If str: The name of a matplotlib colormap (e.g., “viridis”). - If list: A list of specific colors to assign to each class.

  • label_dict (list of str) – The names of the classes corresponding to the columns of y. Used for the legend.

  • minimalist (bool, optional) – If True, suppresses the “ideal” curve (perfect classifier lines) to reduce chart clutter. By default False.

Returns:

The plot is drawn directly onto the provided ax object.

Return type:

None