Gaussian Mixture Models
Bases: exceptions.Exception
Finds the conditional distribution p(X|Y) for a GMM.
Parameters : | Y : NxD array
centroids : list
ccov : list
mc : list
|
---|---|
Returns : | res : tuple
|
Find K cluster centers in X using Expectation Maximization of Gaussian Mixtures.
Parameters : | X : NxD array
max_iter : int
iter_call : callable
delta_stop : float
max_tries : int
diag_add : float
Centroid initialization is given by *cluster_init*, the only available options : are ‘sample’ and ‘kmeans’. ‘sample’ selects random samples as centroids. ‘kmeans’ : calls kmeans to find the cluster centers. : |
---|---|
Returns : | center_list : list
cov_list : list
p_k : list
logLL : list
|
Find K cluster centers in X using Expectation Maximization of Gaussian Mixtures.
Parameters : | X : NxD array
max_iter : int
iter_call : callable
delta_stop : float
max_tries : int
diag_add : float
Centroid initialization is given by *cluster_init*, the only available options : are ‘sample’ and ‘kmeans’. ‘sample’ selects random samples as centroids. ‘kmeans’ : calls kmeans to find the cluster centers. : |
---|---|
Returns : | center_list : list
cov_list : list
p_k : list
logLL : list
|
Difference measures for each component of the GMM.
Parameters : | centroids : list
ccov : list
p_k : list
method : string, optional
|
---|---|
Returns : | diff : NxN np array
|
Returns x,y vectors corresponding to ellipsoid at standard deviation sdwidth.
Assigns each sample to one of the Gaussian clusters given.
Returns an array with numbers, 0 corresponding to the first cluster in the cluster list.
Finds the likelihood for a set of samples belongin to a Gaussian mixture model.
Return log likelighood
Initialize a Gaussian Mixture Model (GMM). Generates a set of inital parameters for the GMM.
Returns : | center_list : list
cov_list : list
p_k : list
|
---|
Evaluates the PDF for the multivariate Guassian mixture.
Draw samples from a Mixture of Gaussians (MoG)
Parameters : | centroids : list
ccov : list
mc : list
individual : bool
|
---|---|
Returns : | prob : 1d np array
|
Evaluates natural log of the PDF for the multivariate Guassian distribution.
Parameters : | X : np array
MU : nparray
SIGMA : 2d np array
|
---|---|
Returns : | prob : 1d np array
|
Finds the marginal distribution p(X) for a GMM.
Parameters : | X_idx : list
centroids : list
ccov : list
mc : list
|
---|---|
Returns : | res : tuple
|
Evaluates the PDF for the multivariate Guassian distribution.
Parameters : | X : np array
MU : nparray
SIGMA : 2d np array
|
---|---|
Returns : | prob : 1d np array
|
Examples
from pypr.clustering import *
from numpy import *
X = array([[0,0],[1,1]])
MU = array([0,0])
SIGMA = diag((1,1))
gmm.mulnormpdf(X, MU, SIGMA)
Predict the entries in X, which contains NaNs.
Parameters : | X : np array
centroids : list
ccov : list
mc : list
|
---|---|
Returns : | Nothing - X is modified : |
Draw samples from a Mixture of Gaussians (MoG)
Parameters : | centroids : list
ccov : list
mc : list
|
---|---|
Returns : | X : 2d np array
|
Examples
from pypr.clustering import *
from numpy import *
centroids=[array([10,10])]
ccov=[array([[1,0],[0,1]])]
samples = 10
gmm.sample_gaussian_mixture(centroids, ccov, samples=samples)
Find centroids based on sample cluster assignments.
Parameters : | X : KxD np array
K : int
m : 1d np array
|
---|---|
Returns : | cc : 2d np array
|
Returns the euclidean distance for each sample to a cluster center
Parameters : | X : 2d np array
c : 1d np array or list
|
---|---|
Returns : | dist : 2d np column array
|
Returns the intra-cluster variance.
Parameters : | X : 2d np array
m : list or 1d np array
cc : 2d np array
|
---|---|
Returns : | dist : float
|
Finds the closest cluster centroid for each sample, and returns cluster membership number.
Parameters : | X : 2d np array
cc : 2d np array
|
---|---|
Returns : | m : 1d array
|
Cluster the samples in X using K-means into K clusters. The algorithm stops when no samples change cluster assignment in an itertaion. NOTE: You might need to change the default maximum number of of iterations iter, depending on the number of samples and clusters used.
Parameters : | X : KxD np array
K : int
iter : int, optional
cluster_init : string, optional
delta_stop : float, optional
verbose : bool, optional
|
---|---|
Returns : | m : 1d np array
cc : 2d np array
|