nltk.cluster.em module¶
- class nltk.cluster.em.EMClusterer[source]¶
Bases:
nltk.cluster.util.VectorSpaceClusterer
The Gaussian EM clusterer models the vectors as being produced by a mixture of k Gaussian sources. The parameters of these sources (prior probability, mean and covariance matrix) are then found to maximise the likelihood of the given data. This is done with the expectation maximisation algorithm. It starts with k arbitrarily chosen means, priors and covariance matrices. It then calculates the membership probabilities for each vector in each of the clusters; this is the ‘E’ step. The cluster parameters are then updated in the ‘M’ step using the maximum likelihood estimate from the cluster membership probabilities. This process continues until the likelihood of the data does not significantly increase.
- __init__(initial_means, priors=None, covariance_matrices=None, conv_threshold=1e-06, bias=0.1, normalise=False, svd_dimensions=None)[source]¶
Creates an EM clusterer with the given starting parameters, convergence threshold and vector mangling parameters.
- Parameters
initial_means ([seq of] numpy array or seq of SparseArray) – the means of the gaussian cluster centers
priors (numpy array or seq of float) – the prior probability for each cluster
covariance_matrices ([seq of] numpy array) – the covariance matrix for each cluster
conv_threshold (int or float) – maximum change in likelihood before deemed convergent
bias (float) – variance bias used to ensure non-singular covariance matrices
normalise (boolean) – should vectors be normalised to length 1
svd_dimensions (int) – number of dimensions to use in reducing vector dimensionsionality with SVD