eelbrain.BoostingResult.cross_predict
- BoostingResult.cross_predict(x=None, data=None, scale='original', name=None)
Predict responses to
x
using complementary training data- Parameters
x (Union[NDVar, str, Sequence[Union[NDVar, str]]]) – Predictors used in the original model fit, or a subset thereof. In order for cross-prediction to be accurate,
x
needs to match thex
used in the original fit exactly in cases and time.data (Dataset) – Dataset with predictors. If
ds
is specified,x
can be omitted.scale (Literal['original', 'normalized']) – Return predictions at the scale of the original data (the
y
supplied to theboosting()
function) or at the normalized scale that is used for model fitting (y
andx
normalized).
- Return type
See also
convolve
Simple prediction of linear model
Notes
This function does not adjust the mean across time of predicted responses; subtract the mean in order to compute explained variance.
Examples
Fit a TRF and reproduce the error using the cross-predict function:
trf = boosting(y, x, 0, 0.5, partitions=5, test=1, partition_results=True) y_pred = trf.cross_predict(x, scale='normalized') y_normalized = (y - trf.y_mean) / trf.y_scale y_residual = y_normalized - y_pred proportion_explained_l1 = 1 - (y_residual.abs().sum('time') / y_normalized.abs().sum('time')) proportion_explained_l2 = 1 - ((y_residual ** 2).sum('time') / (y_normalized ** 2).sum('time'))