himalaya.scoring.r2_score_split¶
- himalaya.scoring.r2_score_split(y_true, y_pred, include_correlation=True)[source]¶
Split the R2 score into individual components using the product measure.
When estimating a linear joint model, the predictions of each feature space are summed:
Yhat_joint = Yhat_A + Yhat_B + ... + Yhat_Z
The joint model R2 can be computed as:
R2_joint = R2(Yhat_joint, Y)
This function estimates the contribution of each feature space to the joint model R2 such that:
R2_joint = R2_A + R2_B + ... + R2_Z
Mathematically, this is achieved by taking into account the correlations between predictions (i.e. Yhat_A*Yhat_B,…, Yhat_A*Yhat_Z). The function can also returns an estimate that ignores these correlations.
This function differs from r2_score_split_svd in the method used to decompose the variance. The function r2_score_split is based on the product measure method, while the function r2_score_split_svd is based on the relative weights method.
This function assumes that y_true is zero-mean over samples.
- Parameters
- y_truearray of shape (n_samples, n_targets)
Observed data. Has to be zero-mean over samples.
- y_predarray of shape (n_kernels, n_samples, n_targets) or (n_samples, n_targets)
Predictions.
- include_correlationbool
Whether to include correlation between feature spaces. If True, individual feature space R2 sum is equivalent to the joint model R2 (i.e. from y_pred.sum(0)).
- Returns
- r2array (n_kernels, n_targets) or (n_targets, )
Individual feature space R2 scores.