algorithms.clustering.von_mises_fisher_mixture

Module: algorithms.clustering.von_mises_fisher_mixture

Inheritance diagram for nipy.algorithms.clustering.von_mises_fisher_mixture:

Inheritance diagram of 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)

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)

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)

density_per_component(x)

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

estimate(x, maxiter=100, miniter=1, bias=None)

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

estimate_means(x, z)

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_weights(z)

Calculate and set weights from z

Parameters:z: array of shape(self.k)
log_density_per_component(x)

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

log_weighted_density(x)

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)

Return mixture density

Parameters:

x: array fo shape(n,3)

should be on the unit sphere

Returns:

like: array of shape(n)

responsibilities(x)

Return responsibilities

Parameters:

x: array fo shape(n,3)

should be on the unit sphere

Returns:

resp: array of shape(n, self.k)

show(x)

Visualization utility

Parameters:

x: array fo shape(n,3)

should be on the unit sphere

weighted_density(x)

Return weighted density

Parameters:

x: array shape(n,3)

should be on the unit sphere

Returns:

like: array

of shape(n, self.k)

Functions

nipy.algorithms.clustering.von_mises_fisher_mixture.estimate_robust_vmm(k, precision, null_class, x, ninit=10, bias=None, maxiter=100)

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.example_cv_nonoise()
nipy.algorithms.clustering.von_mises_fisher_mixture.example_noisy()
nipy.algorithms.clustering.von_mises_fisher_mixture.select_vmm(krange, precision, null_class, x, ninit=10, bias=None, maxiter=100, verbose=0)

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)

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

nipy.algorithms.clustering.von_mises_fisher_mixture.sphere_density(npoints)

Return the points and area of a npoints**2 points sampled on a sphere

Returns:

s : array of shape(npoints ** 2, 3)

area: array of shape(npoints)