kdiagram.plot.evaluation.plot_polar_roc

kdiagram.plot.evaluation.plot_polar_roc(y_true, *y_preds, names=None, title='Polar ROC Curve', figsize=(8, 8), cmap='viridis', show_grid=True, grid_props=None, savefig=None, dpi=300)[source]

Plots a Polar Receiver Operating Characteristic (ROC) Curve.

This function visualizes the performance of binary classification models by mapping the standard ROC curve onto a polar plot. It is a novel visualization developed as part of the analytics framework in [1].

Parameters:
y_truenp.ndarray

1D array of true binary labels (0 or 1).

*y_predsnp.ndarray

One or more 1D arrays of predicted probabilities or scores for the positive class.

nameslist of str, optional

Display names for each of the models. If not provided, generic names like 'Model 1' will be generated.

titlestr, default=”Polar ROC Curve”

The title for the plot.

figsizetuple of (float, float), default=(8, 8)

The figure size in inches.

cmapstr, default=’viridis’

The colormap used to assign a unique color to each model’s curve.

show_gridbool, default=True

Toggle the visibility of the polar grid lines.

grid_propsdict, optional

Custom keyword arguments passed to the grid for styling.

savefigstr, optional

The file path to save the plot. If None, the plot is displayed interactively.

dpiint, default=300

The resolution (dots per inch) for the saved figure.

Returns:
axmatplotlib.axes.Axes

The Matplotlib Axes object containing the plot.

Parameters:

See also

plot_polar_pr_curve

A companion plot for precision-recall.

sklearn.metrics.roc_curve

The underlying scikit-learn function.

Notes

A Receiver Operating Characteristic (ROC) curve is a standard tool for evaluating binary classifiers [2]. It plots the True Positive Rate (TPR) against the False Positive Rate (FPR) at various threshold settings.

(1)\[\text{TPR} = \frac{TP}{TP + FN} \quad , \quad \text{FPR} = \frac{FP}{FP + TN}\]

This function adapts the concept to a polar plot:

  • The angle (θ) is mapped to the False Positive Rate, spanning from 0 at 0° to 1 at 90°.

  • The radius (r) is mapped to the True Positive Rate, spanning from 0 at the center to 1 at the edge.

A model with no skill (random guessing) is represented by a perfect Archimedean spiral. A good model will have a curve that bows outwards, maximizing the area under the curve (AUC).

References

Examples

>>> import numpy as np
>>> from sklearn.datasets import make_classification
>>> from kdiagram.plot.evaluation import plot_polar_roc
>>>
>>> # Generate synthetic binary classification data
>>> X, y_true = make_classification(
...     n_samples=500, n_classes=2, random_state=42
... )
>>>
>>> # Simulate predictions from two models
>>> y_pred_good = y_true * 0.7 + np.random.rand(500) * 0.3
>>> y_pred_bad = np.random.rand(500)
>>>
>>> # Generate the plot
>>> ax = plot_polar_roc(
...     y_true,
...     y_pred_good,
...     y_pred_bad,
...     names=["Good Model", "Random Model"]
... )