eelbrain.BoostingResult
- class eelbrain.BoostingResult(y, x, tstart, tstop, scale_data, delta, mindelta, error, selective_stopping, y_mean, y_scale, x_mean, x_scale, _h, _isnan, t_run, basis, basis_window, splits=None, n_samples=None, _y_info=<factory>, _y_dims=None, i_test=None, l1_residual=None, l2_residual=None, l1_total=None, l2_total=None, r=None, r_rank=None, r_l1=None, partition_results=None, version=15, algorithm_version=-1, execution_context=None, y_pred=None, fit=None)
Result from boosting
Fit metrics are computed from all time points in
y.For models estimated with
test=False, the entirey_predis predicted with the averaged TRF from the different runs (with each run corresponding to one validation set).For models estimated with
test=True,y_predin each test segment is predicted from the averaged TRF from the corresponding training runs (each non-test segment used as validation set once), and the different test segments are then concatenated to compute the fit-metrics in comparison withy.
- Variables:
h (NDVar | tuple of NDVar) – The temporal response function (the average of all TRFs from the different runs/partitions). Whether
his anNDVaror atupleofNDVardepends on whether thexparameter toboosting()was anNDVaror a sequence ofNDVar.h_scaled (NDVar | tuple of NDVar) –
hscaled such that it applies to the original inputyandx. If boosting was done withscale_data=False,h_scaledis the same ash.h_source (NDVar | tuple of NDVar) – If
hwas constructed using a basis,h_sourcerepresents the source ofhbefore being convolved with the basis.h_time (UTS) – Time dimension of the kernel.
r (float | NDVar) – Correlation between the measured response
yand the predicted responseh * x. When using cross-validation (callingboosting()withtest=True), each partition ofyis predicted using thehestimated from the corresponding training partitions. Otherwise, all ofyis estimated using the averageh. For vector data, measured and predicted responses are normalized, andris computed as the average dot product over time. The type ofrdepends on theyparameter toboosting(): Ifyis one-dimensional,ris scalar, otherwise it is aNDVar. Note thatrdoes not take into account the model’s ability to predict the magnitude of the response, only its shape; for a measure that reflects both, consider usingproportion_explained.r_rank (float | NDVar) – As
r, the Spearman rank correlation.t_run (float) – Time it took to run the boosting algorithm (in seconds).
error (str) – The error evaluation method used.
The residual of the final result
error='l1': the sum of the absolute differences betweenyandh * x.error='l2': the sum of the squared differences betweenyandh * x.
For vector
y, the error is defined based on the distance in space for each data point.delta (scalar) – Kernel modification step used.
mindelta (None | scalar) – Mindelta parameter used.
n_samples (int) – Number of samples in the input data time axis.
proportion_explained (float | NDVar) – The proportion of the variation in
ythat is explained by the model. Calculated as1 - (variation(residual) / variation(y)). Variation is caculated as thel1orl2norm, depending on theerrorthat was used for model fitting. Note that this does not correspond tor**2even forerror='l2', because residuals are not guaranteed to be orthogonal to predictions.scale_data (bool) – Scale_data parameter used.
y_mean (NDVar | scalar) – Mean that was subtracted from
y.y_scale (NDVar | scalar) – Scale by which
ywas divided.x_mean (NDVar | scalar | tuple) – Mean that was subtracted from
x.x_scale (NDVar | scalar | tuple) – Scale by which
xwas divided.splits (Splits) – Data splits used for cross-validation. Use
splits.plot()to visualize the cross-validation scheme.partition_results (list of BoostingResuls) – If
boosting()is called withpartition_results=True, this attribute contains the results for the individual test paritions.algorithm_version (int) –
Version of the algorithm with which the model was estimated
-1: results from before this attribute was added
0: Normalize
xafter applying basis1: Numba implementation
2: Cython multiprocessing implementation (Eelbrain 0.38)
3: Cython based convolution (Eelbrain 0.40)
execution_context (dict) – Information on the context in which the model was estimated.
- Parameters:
y (str | None)
scale_data (bool)
delta (float)
mindelta (float)
error (str)
selective_stopping (int)
y_mean (NDVar)
y_scale (NDVar)
_isnan (ndarray)
t_run (float)
basis (float)
basis_window (str)
splits (Splits)
n_samples (int)
_y_info (dict)
_y_dims (Tuple[Dimension, ...])
i_test (int)
r_l1 (NDVar)
partition_results (List[BoostingResult])
version (int)
algorithm_version (int)
y_pred (NDVar)
fit (Boosting)
Examples
To compare the fit of models estimated with different loss metrics (
errorparameter) calculate the proportion of explained variance, for example:data = datasets._get_continuous() trf_l1 = boosting('y', 'x1', 0, 1, data=data, error='l1', partitions=3, test=1) trf_l2 = boosting('y', 'x1', 0, 1, data=data, error='l2', partitions=3, test=1) l1_explained_variance = 1 - (trf_l1.l2_residual / trf_l1.l2_total) l2_explained_variance = 1 - (trf_l2.l2_residual / trf_l2.l2_total)
Methods
|
Predict responses to |
|
Results from the different test partitions in a |