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, i_validate=None, l1_residual=None, l2_residual=None, l1_total=None, l2_total=None, r=None, r_rank=None, r_l1=None, train_l1_residual=None, train_l2_residual=None, train_l1_total=None, train_l2_total=None, train_r=None, train_r_rank=None, train_r_l1=None, partition_results=None, version=16, algorithm_version=-1, execution_context=None, y_pred=None, fit=None)[source]
Result from boosting
Fit metrics are computed from all time points in
y.For models estimated with cross-validation (
test=1, the default),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.For models estimated with
test=0, fit metrics are not computed (None), because they could only be computed from the same data that were used to estimate the TRF, and would overestimate the model’s predictive power (see thetestparameter ofboosting()). Withpartition_results=True, the fit of each run to its validation and training data is available inBoostingResult.partition_results.
- Parameters:
y (str | None)
scale_data (bool)
delta (float)
mindelta (float)
error (str)
selective_stopping (int)
_isnan (ndarray)
t_run (float)
basis (float)
basis_window (str)
splits (Splits)
n_samples (int)
_y_info (dict)
i_test (int)
i_validate (int)
r_l1 (NDVar)
train_r_l1 (NDVar)
partition_results (list[BoostingResult])
version (int)
algorithm_version (int)
y_pred (NDVar)
fit (Boosting)
- h
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
hscaled such that it applies to the original inputyandx. If boosting was done withscale_data=False,h_scaledis the same ash.
- h_source
If
hwas constructed using a basis,h_sourcerepresents the source ofhbefore being convolved with the basis.
- r
Correlation between the measured response
yand the predicted responseh * x. With cross-validation (the default,boosting()withtest=1), each partition ofyis predicted using thehestimated from the corresponding training partitions. Withtest=0,risNone(see above). 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.- Type:
- residual
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.
- n_samples
Number of samples in the data described by the fit metrics (all data unless only a single test partition was evaluated).
- Type:
- proportion_explained
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. As forr, this isNonefor models estimated withtest=0.
- y_mean
Mean that was subtracted from
y.- Type:
- y_scale
Scale by which
ywas divided.- Type:
- x_mean
Mean that was subtracted from
x.- Type:
eelbrain._data_obj.NDVar | float | tuple[eelbrain._data_obj.NDVar | float, …]
- x_scale
Scale by which
xwas divided.- Type:
eelbrain._data_obj.NDVar | float | tuple[eelbrain._data_obj.NDVar | float, …]
- splits
Data splits used for cross-validation. Use
Splits.plot()to visualize the cross-validation scheme.
- partition_results
If
boosting()is called withpartition_results=True, this attribute contains the results for the individual test partitions (test=1), or for the individual validation partitions (test=0). For validation partitions, fit metrics (e.g.,r) reflect the fit to the validation data, andtrain_*attributes the fit to the training data. Note that the fit to the validation data is also biased upward, because the validation data determined when boosting stopped.BoostingResult.partition_result_data()combines them in aDataset.
- i_test
Index of the test partition whose data the fit metrics describe (see
Split.i_test): set for results inBoostingResult.partition_resultsof models estimated withtest=1, and for results fromBoosting.evaluate_fit()withi_test.Nonewhen fit metrics pool all test partitions.- Type:
- i_validate
For results in
BoostingResult.partition_resultsof models estimated withtest=0: index of the validation partition (seeSplit.i_validate).- Type:
- train_r, train_r_rank, train_r_l1, train_residual, train_proportion_explained
Fit to the training data (only for results in
BoostingResult.partition_resultsof models estimated withtest=0).
- algorithm_version
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)
- Type:
- execution_context
Information on the context in which the model was estimated.
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) trf_l2 = boosting('y', 'x1', 0, 1, data=data, error='l2', partitions=3) 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 partitions in a |