Skip to main content

functional_explained_variance

Function functional_explained_variance 

Source
pub fn functional_explained_variance(
    y_true: &FdMatrix,
    y_pred: &FdMatrix,
    argvals: &[f64],
) -> Result<f64, FdarError>
Expand description

Functional Explained Variance Score integrated over argvals.

Computes the explained variance per curve as: EV_i = 1 - SS_res_i / SS_tot_i where:

  • SS_res_i = ∫ (residual_i(t) - mean_residual_i)^2 dt
  • SS_tot_i = ∫ (y_true_i(t) - mean_true_i)^2 dt
  • Means are computed as the weighted integral divided by the domain length.

The score is then averaged over all curves. Returns 1.0 for perfect prediction, 0.0 when prediction equals the mean of y_true, and can be negative for predictions worse than the mean baseline.

When SS_tot_i ≈ 0 (constant true curve) and SS_res_i ≈ 0 (perfect fit), returns 1.0 for that curve (trivial perfect prediction). When SS_tot_i ≈ 0 but SS_res_i > 0, returns 0.0 (prediction adds no value over a constant).

§Errors