R2#

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

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

Warning

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

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

Parameters:
namestr, default=’r2’

The name of this metric.

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

The values to request for scoring.

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

The dimension(s) to reduce over.

fCallable, default=mvpy.math.r2

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 r2
>>> X, y = make_meeg_categorical()
>>> clf = RidgeClassifier()
>>> cross_val_score(clf, X, y, metric = r2)