frites.estimator.ResamplingEstimator#
- class frites.estimator.ResamplingEstimator(estimator, n_resampling=100, verbose=None)[source]#
Trial-resampling estimator.
In case of unbalanced contrast (i.e. when the number of trials per condition is very different) it can be interesting to use a trial-resampling technique to minimize the possibility that the effect size is driven by the number of trials. To this end, the same number of trials is used to estimate the effect size and the final
- Parameters
- estimator
frites.estimator
An estimator object (e.g. GCMIEstimator, CorrEstimator etc.)
- n_resampling
python:int
| 100 Number of resampling to perform
- estimator
Methods
estimate
(x, y[, z, categories])Estimate the amount of information shared with resampling.
Get the function to execute according to the input parameters.
- estimate(x, y, z=None, categories=None)[source]#
Estimate the amount of information shared with resampling.
This method is made for estimating information on 3D variables (i.e (n_var, n_mv, n_samples)) where n_var is an additional dimension (e.g times, times x freqs etc.), n_mv is a multivariate axis and n_samples the number of samples. When computing MI, both the multivariate and samples axes are reduced.
In contrast to other estimators, the resampling estimator need to know whether the trials belong to the first or second condition. Therefore, a vector of discrete conditions need to be provided, depending of the type of information :
If mi_type is ‘cc’ : x and y should be continuous variables and z should contains the discrete classes
If mi_type is ‘cd’ : x should be continuous and the y variables is used to find the discrete classes
- Parameters
- xnumpy:array_like
Array of shape (n_var, n_mv, n_samples).
- ynumpy:array_like
Array with a shape that depends on the type of MI (mi_type) :
If mi_type is ‘cc’, y should be an array with the same shape as x
If mi_type is ‘cd’, y should be a row vector of shape (n_samples,). In that case, the discrete values of y are used to identify the discrete classes
- znumpy:array_like |
python:None
Array containing discrete classes in case mi_type is ‘cc’. Should be a vector of shape (n_samples,)
- categoriesnumpy:array_like |
python:None
Row vector of categories. This vector should have a shape of (n_samples,) and should contains integers describing the category of each sample.
- Returns
- infonumpy:array_like
Array of information of shape (n_categories, n_var). If categories is None when computing information, n_categories is going to be one.
Examples using
estimate
:Trial-resampling: correcting for unbalanced designs
Trial-resampling: correcting for unbalanced designs
- get_function()[source]#
Get the function to execute according to the input parameters.
This can be particularly useful when computing resampling in parallel as it avoids to pickle the whole estimator and therefore, leading to faster computations.
The returned function has the following signature :
fcn(x, y, z=None, categories=None)
and return an array of shape (n_categories, n_var).
Examples using frites.estimator.ResamplingEstimator
#
Trial-resampling: correcting for unbalanced designs