algorithms.clustering.von_mises_fisher_mixture¶
Module: algorithms.clustering.von_mises_fisher_mixture
¶
Inheritance diagram for nipy.algorithms.clustering.von_mises_fisher_mixture
:
Implementation of Von-Mises-Fisher Mixture models, i.e. the equaivalent of mixture of Gaussian on the sphere.
Author: Bertrand Thirion, 2010-2011
Class¶
VonMisesMixture
¶
-
class
nipy.algorithms.clustering.von_mises_fisher_mixture.
VonMisesMixture
(k, precision, means=None, weights=None, null_class=False)[source]¶ Bases:
object
Model for Von Mises mixture distribution with fixed variance on a two-dimensional sphere
-
__init__
(k, precision, means=None, weights=None, null_class=False)[source]¶ Initialize Von Mises mixture
- Parameters
k: int,
number of components
precision: float,
the fixed precision parameter
means: array of shape(self.k, 3), optional
input component centers
weights: array of shape(self.k), optional
input components weights
null_class: bool, optional
Inclusion of a null class within the model (related to k=0)
-
log_density_per_component
(x)[source]¶ Compute the per-component density of the data
- Parameters
x: array fo shape(n,3)
should be on the unit sphere
- Returns
like: array of shape(n, self.k), with non-neagtive values
the density
-
density_per_component
(x)[source]¶ Compute the per-component density of the data
- Parameters
x: array fo shape(n,3)
should be on the unit sphere
- Returns
like: array of shape(n, self.k), with non-neagtive values
the density
-
weighted_density
(x)[source]¶ Return weighted density
- Parameters
x: array shape(n,3)
should be on the unit sphere
- Returns
like: array
of shape(n, self.k)
-
log_weighted_density
(x)[source]¶ Return log weighted density
- Parameters
x: array fo shape(n,3)
should be on the unit sphere
- Returns
log_like: array of shape(n, self.k)
-
mixture_density
(x)[source]¶ Return mixture density
- Parameters
x: array fo shape(n,3)
should be on the unit sphere
- Returns
like: array of shape(n)
-
responsibilities
(x)[source]¶ Return responsibilities
- Parameters
x: array fo shape(n,3)
should be on the unit sphere
- Returns
resp: array of shape(n, self.k)
-
estimate_means
(x, z)[source]¶ Calculate and set means from x and z
- Parameters
x: array fo shape(n,3)
should be on the unit sphere
z: array of shape(self.k)
-
estimate
(x, maxiter=100, miniter=1, bias=None)[source]¶ Return average log density across samples
- Parameters
x: array of shape (n,3)
should be on the unit sphere
maxiter : int, optional
maximum number of iterations of the algorithms
miniter : int, optional
minimum number of iterations
bias : array of shape(n), optional
prior probability of being in a non-null class
- Returns
ll : float
average (across samples) log-density
-
Functions¶
-
nipy.algorithms.clustering.von_mises_fisher_mixture.
estimate_robust_vmm
(k, precision, null_class, x, ninit=10, bias=None, maxiter=100)[source]¶ Return the best von_mises mixture after severla initialization
- Parameters
k: int, number of classes
precision: float, priori precision parameter
null class: bool, optional,
should a null class be included or not
x: array fo shape(n,3)
input data, should be on the unit sphere
ninit: int, optional,
number of iterations
bias: array of shape(n), optional
prior probability of being in a non-null class
maxiter: int, optional,
maximum number of iterations after each initialization
-
nipy.algorithms.clustering.von_mises_fisher_mixture.
select_vmm
(krange, precision, null_class, x, ninit=10, bias=None, maxiter=100, verbose=0)[source]¶ Return the best von_mises mixture after severla initialization
- Parameters
krange: list of ints,
number of classes to consider
precision:
null class:
x: array fo shape(n,3)
should be on the unit sphere
ninit: int, optional,
number of iterations
maxiter: int, optional,
bias: array of shape(n),
a prior probability of not being in the null class
verbose: Bool, optional
-
nipy.algorithms.clustering.von_mises_fisher_mixture.
select_vmm_cv
(krange, precision, x, null_class, cv_index, ninit=5, maxiter=100, bias=None, verbose=0)[source]¶ Return the best von_mises mixture after severla initialization
- Parameters
krange: list of ints,
number of classes to consider
precision: float,
precision parameter of the von-mises densities
x: array fo shape(n, 3)
should be on the unit sphere
null class: bool, whether a null class should be included or not
cv_index: set of indices for cross validation
ninit: int, optional,
number of iterations
maxiter: int, optional,
bias: array of shape (n), prior