jsat.clustering
Class EMGaussianMixture
- java.lang.Object
-
- jsat.clustering.EMGaussianMixture
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, Clusterer, KClusterer, MultivariateDistribution
public class EMGaussianMixture extends java.lang.Object implements KClusterer, MultivariateDistribution
An implementation of Gaussian Mixture models that learns the specified number of Gaussians using Expectation Maximization algorithm.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description EMGaussianMixture()EMGaussianMixture(EMGaussianMixture gm)Copy constructor.EMGaussianMixture(SeedSelectionMethods.SeedSelection seedSelection)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description EMGaussianMixtureclone()int[]cluster(DataSet dataSet, boolean parallel, int[] designations)Performs clustering on the given data set.int[]cluster(DataSet dataSet, int[] designations)Performs clustering on the given data set.int[]cluster(DataSet dataSet, int clusters, boolean parallel, int[] designations)int[]cluster(DataSet dataSet, int lowK, int highK, boolean parallel, int[] designations)int[]cluster(DataSet dataSet, int lowK, int highK, int[] designations)intgetIterationLimit()Returns the maximum number of iterations of the ElkanKMeans algorithm that will be performed.SeedSelectionMethods.SeedSelectiongetSeedSelection()doublelogPdf(Vec x)Computes the log of the probability density function.doublepdf(Vec x)Returns the probability of a given vector from this distribution.java.util.List<Vec>sample(int count, java.util.Random rand)Performs sampling on the current distribution.voidsetIterationLimit(int iterLimit)Sets the maximum number of iterations allowedvoidsetSeedSelection(SeedSelectionMethods.SeedSelection seedSelection)Sets the method of seed selection to use for this algorithm.booleansetUsingData(DataSet dataSet, boolean parallel)Sets the parameters of the distribution to attempt to fit the given list of data points.<V extends Vec>
booleansetUsingData(java.util.List<V> dataSet, boolean parallel)Sets the parameters of the distribution to attempt to fit the given list of vectors.-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface jsat.clustering.KClusterer
cluster, cluster, cluster, cluster, cluster
-
Methods inherited from interface jsat.clustering.Clusterer
cluster, cluster, supportsWeightedData
-
Methods inherited from interface jsat.distributions.multivariate.MultivariateDistribution
logPdf, pdf, setUsingData, setUsingData, setUsingDataList
-
-
-
-
Constructor Detail
-
EMGaussianMixture
public EMGaussianMixture(SeedSelectionMethods.SeedSelection seedSelection)
-
EMGaussianMixture
public EMGaussianMixture()
-
EMGaussianMixture
public EMGaussianMixture(EMGaussianMixture gm)
Copy constructor. The new Gaussian Mixture can be altered without effecting gm- Parameters:
gm- the Guassian Mixture to duplicate
-
-
Method Detail
-
setSeedSelection
public void setSeedSelection(SeedSelectionMethods.SeedSelection seedSelection)
Sets the method of seed selection to use for this algorithm.SeedSelectionMethods.SeedSelection.KPPis recommended for this algorithm in particular.- Parameters:
seedSelection- the method of seed selection to use
-
getSeedSelection
public SeedSelectionMethods.SeedSelection getSeedSelection()
- Returns:
- the method of seed selection used
-
setIterationLimit
public void setIterationLimit(int iterLimit)
Sets the maximum number of iterations allowed- Parameters:
iterLimit- the maximum number of iterations of the ElkanKMeans algorithm
-
getIterationLimit
public int getIterationLimit()
Returns the maximum number of iterations of the ElkanKMeans algorithm that will be performed.- Returns:
- the maximum number of iterations of the ElkanKMeans algorithm that will be performed.
-
logPdf
public double logPdf(Vec x)
Description copied from interface:MultivariateDistributionComputes the log of the probability density function. If the probability of the input is zero, the log of zero would beDouble.NEGATIVE_INFINITY. Instead, -Double.MAX_VALUEis returned.- Specified by:
logPdfin interfaceMultivariateDistribution- Parameters:
x- the vector the get the log probability of- Returns:
- the log of the probability.
-
pdf
public double pdf(Vec x)
Description copied from interface:MultivariateDistributionReturns the probability of a given vector from this distribution. By definition, the probability will always be in the range [0, 1].- Specified by:
pdfin interfaceMultivariateDistribution- Parameters:
x- the vector the get the log probability of- Returns:
- the probability
-
setUsingData
public <V extends Vec> boolean setUsingData(java.util.List<V> dataSet, boolean parallel)
Description copied from interface:MultivariateDistributionSets the parameters of the distribution to attempt to fit the given list of vectors. All vectors are assumed to have the same weight.- Specified by:
setUsingDatain interfaceMultivariateDistribution- Type Parameters:
V- the vector type- Parameters:
dataSet- the list of data pointsparallel-trueif the training should be done using multiple-cores,falsefor single threaded.- Returns:
- true if the distribution was fit to the data, or false if the distribution could not be fit to the data set.
-
setUsingData
public boolean setUsingData(DataSet dataSet, boolean parallel)
Description copied from interface:MultivariateDistributionSets the parameters of the distribution to attempt to fit the given list of data points. Theweightsof the data points will be used.- Specified by:
setUsingDatain interfaceMultivariateDistribution- Parameters:
dataSet- the data set to useparallel- the source of threads for computation- Returns:
- true if the distribution was fit to the data, or false if the distribution could not be fit to the data set.
-
clone
public EMGaussianMixture clone()
- Specified by:
clonein interfaceClusterer- Specified by:
clonein interfaceKClusterer- Specified by:
clonein interfaceMultivariateDistribution- Overrides:
clonein classjava.lang.Object
-
sample
public java.util.List<Vec> sample(int count, java.util.Random rand)
Description copied from interface:MultivariateDistributionPerforms sampling on the current distribution.- Specified by:
samplein interfaceMultivariateDistribution- Parameters:
count- the number of iid samples to drawrand- the source of randomness- Returns:
- a list of sample vectors from this distribution
-
cluster
public int[] cluster(DataSet dataSet, int[] designations)
Description copied from interface:ClustererPerforms clustering on the given data set. Parameters may be estimated by the method, or other heuristics performed.- Specified by:
clusterin interfaceClusterer- Parameters:
dataSet- the data set to perform clustering ondesignations- the array which will contain the designated values. The array will be altered and returned by the function. If null is given, a new array will be created and returned.- Returns:
- an array indicating for each value indicating the cluster designation. This is the same array as designations, or a new one if the input array was null
-
cluster
public int[] cluster(DataSet dataSet, boolean parallel, int[] designations)
Description copied from interface:ClustererPerforms clustering on the given data set. Parameters may be estimated by the method, or other heuristics performed.- Specified by:
clusterin interfaceClusterer- Parameters:
dataSet- the data set to perform clustering onparallel-trueif multiple threads should be used to perform clustering.falseif it should be done in a single threaded manner.designations- the array which will contain the designated values. The array will be altered and returned by the function. If null is given, a new array will be created and returned.- Returns:
- the int[]
-
cluster
public int[] cluster(DataSet dataSet, int clusters, boolean parallel, int[] designations)
- Specified by:
clusterin interfaceKClusterer
-
cluster
public int[] cluster(DataSet dataSet, int lowK, int highK, boolean parallel, int[] designations)
- Specified by:
clusterin interfaceKClusterer
-
cluster
public int[] cluster(DataSet dataSet, int lowK, int highK, int[] designations)
- Specified by:
clusterin interfaceKClusterer
-
-
DataMelt 3.0 © DataMelt by jWork.ORG