Inheritance diagram for nipy.neurospin.clustering.gmm:
Gaussian Mixture Model Class: contains the basic fields and methods of GMMs The class GMM _old uses C bindings which are computationally and memory efficient.
Author : Bertrand Thirion, 2006-2009
Standard GMM.
this class contains the following fields k (int): the number of components in the mixture dim (int): is the dimension of the data prec_type = ‘full’ (string) is the parameterization
of the precisions/covariance matrices: either ‘full’ or ‘diagonal’.
weights: array of shape(k): weights of the mixture
fixme : - no copy method
Methods
Initialize the structure, at least with the dimensions of the problem
| Parameters: | k (int) the number of classes of the model : dim (int) the dimension of the problem : prec_type = ‘full’ : coavriance:precision parameterization
means = None: array of shape (self.k,self.dim) : precisions = None: array of shape (self.k,self.dim,self.dim) :
weights=None: array of shape (self.k) : By default, means, precision and weights are set as : zeros() : eye() : 1/k ones() : with the correct dimensions : |
|---|
returns the averaged log-likelihood of the model for the dataset x
| Parameters: | x: array of shape (nbitems,self.dim) :
tiny = 1.e-15: a small constant to avoid numerical singularities : |
|---|
computation of bic approximation of evidence
| Parameters: | like, array of shape (nbitem,self.k) :
tiny=1.e-15, a small constant to avoid numerical singularities : |
|---|---|
| Returns: | the bic value : |
essentially check that x.shape[1]==self.dim
x is returned with possibly reshaping
estimation of self given a dataset x
| Parameters: | x array of shape (nbitem,dim) :
niter=100: maximal number of iterations in the estimation process : delta = 1.e-4: increment of data likelihood at which :
verbose=0: verbosity mode : |
|---|---|
| Returns: | bic : an asymptotic approximation of model evidence |
computation of bic approximation of evidence
| Parameters: | x array of shape (nbitems,dim) :
|
|---|---|
| Returns: | the bic value : |
Set the regularizing priors as weakly informative according to Fraley and raftery; Journal of Classification 24:155-181 (2007)
| Parameters: | x array of shape (nbitems,dim) :
|
|---|
this function initializes self according to a certain dataset x: 1. sets the regularizing hyper-parameters 2. initializes z using a k-means algorithm, then 3. upate the parameters
| Parameters: | x, array of shape (nbitems,self.dim) :
|
|---|
estimation of self given x
| Parameters: | x array of shape (nbitem,dim) :
z = None: array of shape (nbitem) :
niter=100: maximal number of iterations in the estimation process : delta = 1.e-4: increment of data likelihood at which :
ninit=1: number of initialization performed :
verbose=0: verbosity mode : |
|---|---|
| Returns: | the best model is returned : |
return the likelihood of the model for the data x the values are weighted by the components weights
| Parameters: | x array of shape (nbitems,self.dim) :
|
|---|---|
| Returns: | like, array of shape(nbitem,self.k) :
|
return the MAP labelling of x
| Parameters: | x array of shape (nbitem,dim) :
like=None array of shape(nbitem,self.k) :
|
|---|---|
| Returns: | z: array of shape(nbitem): the resulting MAP labelling :
|
returns the likelihood of the mixture for x
| Parameters: | x: array of shape (nbitems,self.dim) :
|
|---|
Set manually the weights, means and precision of the model
| Parameters: | means: array of shape (self.k,self.dim) : precisions: array of shape (self.k,self.dim,self.dim) :
weights: array of shape (self.k) : |
|---|
compute the population, i.e. the statistics of allocation
| Parameters: | l array of shape (nbitem,self.k): :
|
|---|
Function to plot a GMM – Currently, works only in 1D
| Parameters: | x: array of shape(nbitems,dim) :
gd: grid descriptor structure : density = None: :
mpaxes = None: axes handle to make the figure :
|
|---|
returns the log-likelihood of the mixture for x
| Parameters: | x array of shape (nbitems,self.dim) :
|
|---|---|
| Returns: | ll: array of shape(nbitems) :
|
return the likelihood of each data for each component the values are not weighted by the component weights
| Parameters: | x: array of shape (nbitems,self.dim) :
|
|---|---|
| Returns: | like, array of shape(nbitem,self.k) :
|
Given a certain dataset x, find the best-fitting GMM within a certain range indexed by krange
| Parameters: | x array of shape (nbitem,dim) :
krange (list of floats) the range of values to test for k : prec_type =’full’, string (to be chosen within ‘full’,’diag’) :
niter=100, int, maximal number of iterations in the estimation process : delta = 1.e-4n float increment of data likelihood at which :
ninit = 1, int number of initialization performed :
verbose=0: verbosity mode : |
|---|---|
| Returns: | mg : the best-fitting GMM |
Given a set of points in a plane and a GMM, plot them
| Parameters: | x : array of shape (npoints,dim=2) my_gmm: a gmm whose density has to be ploted : z = None: array of shape (npoints) :
show = 0: do we show the image : verbose=0 : verbosity mode withDots=True, bool :
logScale=False, bool :
mpaxes=None, int :
|
|---|---|
| Returns: | gd, grid_descriptor instance, :
ax, handle to the figure axes : |