explained_variance_score#

skfda.misc.scoring.explained_variance_score(y_true, y_pred, *, sample_weight=None, multioutput='uniform_average')[source]#
skfda.misc.scoring.explained_variance_score(y_true, y_pred, *, sample_weight=None, multioutput='uniform_average')
skfda.misc.scoring.explained_variance_score(y_true: DataType, y_pred: DataType, *, sample_weight: NDArrayFloat | None = None, multioutput: Literal['uniform_average'] = 'uniform_average') float
skfda.misc.scoring.explained_variance_score(y_true: DataType, y_pred: DataType, *, sample_weight: NDArrayFloat | None = None, multioutput: Literal['raw_values']) DataType

Explained variance score for FData.

With \(y\_true = (X_1, X_2, ..., X_n)\) being the real values, \(t\_pred = (\hat{X}_1, \hat{X}_2, ..., \hat{X}_n)\) being the estimated and \(sample\_weight = (w_1, w_2, ..., w_n)\), the score is calculated as

\[EV(y\_true, y\_pred)(t) = 1 - \frac{Var(y\_true(t) - y\_pred(t), sample\_weight)} {Var(y\_true(t), sample\_weight)}\]

where \(Var\) is a weighted variance.

Weighted variance is defined as below

\[Var(y\_true, sample\_weight)(t) = \sum_{i=1}^n w_i (X_i(t) - Mean(fd(t), sample\_weight))^2.\]

Here, \(Mean\) is a weighted mean.

For \(y\_true\) and \(y\_pred\) of type FDataGrid, \(EV\) is also a FDataGrid object with the same grid points.

If multioutput = ‘raw_values’, the function \(EV\) is returned. Otherwise, if multioutput = ‘uniform_average’, the mean of \(EV\) is calculated:

\[mean(EV) = \frac{1}{V}\int_{D} EV(t) dt\]

where \(D\) is the function domain and \(V\) the volume of that domain.

For FDataBasis only ‘uniform_average’ is available.

If \(y\_true\) and \(y\_pred\) are numpy arrays, sklearn function is called.

The best possible score is 1.0, lower values are worse.

Parameters:
  • y_true – Correct target values.

  • y_pred – Estimated values.

  • sample_weight – Sample weights. By default, uniform weights are taken.

  • multioutput – Defines format of the return.

Returns:

Explained variance score.

If multioutput = ‘uniform_average’ or \(y\_pred\) and \(y\_true\) are FDataBasis objects, float is returned.

If both \(y\_pred\) and \(y\_true\) are FDataGrid objects and multioutput = ‘raw_values’, FDataGrid is returned.

If both \(y\_pred\) and \(y\_true\) are ndarray and multioutput = ‘raw_values’, ndarray.