Roc_auc#

class mvpy.metrics.Roc_auc(name: str = 'roc_auc', request: str | ~typing.Tuple[str] = ('y', 'decision_function'), reduce: int | ~typing.Tuple[int] = (0, ), f: ~typing.Callable = <function roc_auc>)[source]#

Implements mvpy.math.roc_auc() as a Metric.

Warning

This class extends Metric. If you would like to apply this metric, please use the instance exposed under mvpy.metrics.roc_auc.

For more information on this, please consult the documentation of Metric and score().

Parameters:
namestr, default=’roc_auc’

The name of this metric.

requeststr | tuple[str], default=(‘y’, ‘decision_function’)

The values to request for scoring.

reduceint | tuple[int], default= (0,)

The dimension(s) to reduce over.

fCallable, default=mvpy.math.roc_auc

The function to call.

Examples

>>> import torch
>>> from mvpy.dataset import make_meeg_categorical
>>> from mvpy.estimators import RidgeClassifier
>>> from mvpy.crossvalidation import cross_val_score
>>> from mvpy.metric import roc_auc
>>> X, y = make_meeg_categorical()
>>> clf = RidgeClassifier()
>>> cross_val_score(clf, X, y, metric = roc_auc)
__call__(y: ndarray | Tensor, df: ndarray | Tensor) ndarray | Tensor[source]#

Compute ROC-AUC scores.

This overwrites the default behaviour specified in Metric to make sure ROC-AUC scores are computed appropriately per feature, even when there is an additional time dimension.

Parameters:
ynp.ndarray | torch.Tensor

The true labels of shape (n_features, [n_timepoints, ]n_samples).

dfnp.ndarray | torch.Tensor

The decision functions of shape (n_classes, [n_timepoints, ]n_samples).

Returns:
roc_aucnp.ndarray | torch.Tensor

The score of shape (n_features[, n_timepoints]).