frites.estimator.BinMIEstimator#
- class frites.estimator.BinMIEstimator(mi_type='cc', n_bins=4, verbose=None)[source]#
Binning-based Mutual-Information estimator.
Note
The functions for estimating the mutual-information using binning are relatively slow. If Numba is installed, those functions can be considerably accelerated.
- Parameters
- mi_type{‘cc’, ‘cd’, ‘ccd’}
Mutual information type (default : ‘cc’) :
‘cc’ : MI between two continuous variables
‘cd’ : MI between a continuous and a discret variables
‘ccd’ : MI between two continuous variables conditioned by a third discret one
- n_bins
python:int
| 4 Number of bins to estimate the probability distribution.
Methods
estimate
(x, y[, z, categories])Estimate the (possibly conditional) mutual-information.
Get the function to execute according to the input parameters.
- estimate(x, y, z=None, categories=None)[source]#
Estimate the (possibly conditional) mutual-information.
This method is made for computing the mutual-information on 3D variables (i.e (n_var, 1, n_samples)) where n_var is an additional dimension (e.g times, times x freqs etc.), 1 is a multivariate axis and n_samples the number of samples. When computing MI, both the multivariate and samples axes are reduced.
- Parameters
- xnumpy:array_like
Array of shape (n_var, 1, n_samples). If x has more than three dimensions, it’s going to be internally reshaped.
- ynumpy:array_like
Array with a shape that depends on the type of MI (mi_type) :
If mi_type is ‘cc’ or ‘ccd’, 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,)
- znumpy:array_like |
python:None
Array for conditional mutual-information. The shape is going to depend on the type of MI (mi_type) :
If mi_type is ‘ccd’, z should be a row vector of shape (n_samples,)
If mi_type is ‘ccc’, z should have the same shape as x and y
- 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. If categories are provided, the copnorm is going to be performed per categories.
- Returns
- minumpy:array_like
Array of (possibly conditional) mutual-information of shape (n_categories, n_var). If categories is None when computing MI, n_categories is going to be one.
- get_function()[source]#
Get the function to execute according to the input parameters.
This can be particularly useful when computing MI 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).