Click or drag to resize
Accord.NET (logo)

GaussianMixtureModel Class

Gaussian mixture model clustering.
Inheritance Hierarchy
SystemObject
  Accord.MachineLearningParallelLearningBase
    Accord.MachineLearningGaussianMixtureModel

Namespace:  Accord.MachineLearning
Assembly:  Accord.MachineLearning (in Accord.MachineLearning.dll) Version: 3.8.0
Syntax
[SerializableAttribute]
public class GaussianMixtureModel : ParallelLearningBase, 
	IUnsupervisedLearning<GaussianClusterCollection, double[], int>, IClusteringAlgorithm<double[], double>, 
	IClusteringAlgorithm<double[]>, IUnsupervisedLearning<IClusterCollection<double[]>, double[], int>
Request Example View Source

The GaussianMixtureModel type exposes the following members.

Constructors
Properties
  NameDescription
Public propertyClusters Obsolete.
Gets the collection of clusters currently modeled by the clustering algorithm.
Public propertyComputeLabels
Gets or sets whether cluster labels should be computed at the end of the learning iteration. Setting to False might save a few computations in case they are not necessary.
Public propertyComputeLogLikelihood
Gets or sets whether the log-likelihood should be computed at the end of the learning iteration. Setting to False might save a few computations in case they are not necessary.
Public propertyGaussians
Gets the Gaussian components of the mixture model.
Public propertyInitializations
Gets or sets how many random initializations to try. Default is 3.
Public propertyIterations
Public propertyLogLikelihood
Gets the log-likelihood of the model at the last iteration.
Public propertyMaxIterations
Gets or sets the maximum number of iterations to be performed by the method. If set to zero, no iteration limit will be imposed. Default is 0.
Public propertyOptions
Gets or sets the fitting options for the component Gaussian distributions of the mixture model.
Public propertyParallelOptions
Gets or sets the parallelization options for this algorithm.
(Inherited from ParallelLearningBase.)
Public propertyToken
Gets or sets a cancellation token that can be used to cancel the algorithm while it is running.
(Inherited from ParallelLearningBase.)
Public propertyTolerance
Gets or sets the convergence criterion for the Expectation-Maximization algorithm. Default is 1e-3.
Public propertyUseLogarithm
Gets or sets whether to make computations using the log -domain. This might improve accuracy on large datasets.
Top
Methods
  NameDescription
Public methodCompute(Double) Obsolete.
Divides the input data into K clusters modeling each cluster as a multivariate Gaussian distribution.
Public methodCompute(Double, GaussianMixtureModelOptions) Obsolete.
Divides the input data into K clusters modeling each cluster as a multivariate Gaussian distribution.
Public methodCompute(Double, Double) Obsolete.
Divides the input data into K clusters modeling each cluster as a multivariate Gaussian distribution.
Public methodCompute(Double, Double) Obsolete.
Divides the input data into K clusters modeling each cluster as a multivariate Gaussian distribution.
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodInitialize(KMeans)
Initializes the model with initial values obtained through a run of the K-Means clustering algorithm.
Public methodInitialize(MixtureNormalDistribution)
Initializes the model with initial values.
Public methodInitialize(MultivariateMixtureMultivariateNormalDistribution)
Initializes the model with initial values.
Public methodInitialize(MultivariateNormalDistribution)
Initializes the model with initial values.
Public methodInitialize(NormalDistribution)
Initializes the model with initial values.
Public methodInitialize(Double, MultivariateNormalDistribution)
Initializes the model with initial values.
Public methodInitialize(Double, NormalDistribution)
Initializes the model with initial values.
Public methodInitialize(Double, Double)
Initializes the model with initial values obtained through a run of the K-Means clustering algorithm.
Public methodLearn
Learns a model that can map the given inputs to the desired outputs.
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodToMixtureDistribution
Gets a copy of the mixture distribution modeled by this Gaussian Mixture Model.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Extension Methods
  NameDescription
Public Extension MethodHasMethod
Checks whether an object implements a method with the given name.
(Defined by ExtensionMethods.)
Public Extension MethodIsEqual
Compares two objects for equality, performing an elementwise comparison if the elements are vectors or matrices.
(Defined by Matrix.)
Public Extension MethodTo(Type)Overloaded.
Converts an object into another type, irrespective of whether the conversion can be done at compile time or not. This can be used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.)
Public Extension MethodToTOverloaded.
Converts an object into another type, irrespective of whether the conversion can be done at compile time or not. This can be used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.)
Top
Remarks
Gaussian Mixture Models are one of most widely used model-based clustering methods. This specialized class provides a wrap-up around the Mixture<NormalDistribution> distribution and provides mixture initialization using the K-Means clustering algorithm.
Examples
Accord.Math.Random.Generator.Seed = 0;

// Test Samples
double[][] samples =
{
    new double[] { 0, 1 },
    new double[] { 1, 2 },
    new double[] { 1, 1 },
    new double[] { 0, 7 },
    new double[] { 1, 1 },
    new double[] { 6, 2 },
    new double[] { 6, 5 },
    new double[] { 5, 1 },
    new double[] { 7, 1 },
    new double[] { 5, 1 }
};

// Create a new Gaussian Mixture Model with 2 components
GaussianMixtureModel gmm = new GaussianMixtureModel(2);

// Estimate the Gaussian Mixture
var clusters = gmm.Learn(samples);

// Predict cluster labels for each sample
int[] predicted = clusters.Decide(samples);

// We can also obtain the log-likelihoods for each sample:
double[] logLikelihoods = clusters.LogLikelihood(samples);

// As well as the probability of belonging to each cluster
double[][] probabilities = clusters.Probabilities(samples);
See Also