frites.estimator.CustomEstimator#
- class frites.estimator.CustomEstimator(name, mi_type, core_fun, multivariate=True, test=True, verbose=None)[source]#
Wrapper for defining custom estimator of information.
- Parameters
- name
python:str
Estimator name
- mi_type{‘cc’, ‘cd’}
Specify whether the estimator is able to compute information shared between two continuous variables (i.e. regression like ‘cc’) or between a continuous and a discrete variables (i.e. decoding like ‘cd’)
- core_fun
function
The core function to use for estimating information. The function should takes as input two variables (def fcn(x, y)), each of shape (n_var, n_mv, n_samples) where n_samples (or n_epochs, n_trials) is the number of repetitions along which to compute information, n_mv is a multivariate axis and n_var is an additional dimension. The function should returns the amount of information shared between x and y and the resulting array should have a shape of (n_var,)
- multivariatebool |
python:True
Specify whether the estimator is supporting multivariate inputs (True) or not (False)
- testbool |
python:True
Test if the provided core function is valid or not.
- name
Methods
estimate
(x, y[, z, categories])Estimate the amount of information shared with the custom estimator.
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 the custom estimator.
This method is made for estimating the amount of information shared between 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.
- Parameters
- x, ynumpy:array_like
Array of shape (n_var, n_mv, 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).
Examples using
estimate
:Defining a custom estimator
- get_function()[source]#
Get the function to execute according to the input parameters.
This can be particularly useful when computing information in parallel as it avoids to pickle the whole estimator and therefore, leading to faster computations.
The returned function has the following signature :
and return an array of shape (n_categories, n_var).