Documentation of 'jsat.clustering.kmeans.MiniBatchKMeans' Java class
MiniBatchKMeans
jsat.clustering.kmeans

Class MiniBatchKMeans

  • All Implemented Interfaces:
    java.io.Serializable, Clusterer, KClusterer


    public class MiniBatchKMeans
    extends KClustererBase
    Implements the mini-batch algorithms for k-means. This is a stochastic algorithm, so it does not find the global solution. This implementation is parallel, but only the methods that specify the exact number of clusters are supported.

    See: Sculley, D. (2010). Web-scale k-means clustering. Proceedings of the 19th international conference on World wide web (pp. 1177–1178). New York, New York, USA: ACM Press. doi:10.1145/1772690.1772862
    See Also:
    Serialized Form
    • Constructor Detail

      • MiniBatchKMeans

        public MiniBatchKMeans(int batchSize,
                               int iterations)
        Creates a new Mini-Batch k-Means object that uses k-means++ for seed selection and uses the EuclideanDistance.
        Parameters:
        batchSize - the mini-batch size
        iterations - the number of mini batches to perform
      • MiniBatchKMeans

        public MiniBatchKMeans(DistanceMetric dm,
                               int batchSize,
                               int iterations)
        Creates a new Mini-Batch k-Means object that uses k-means++ for seed selection.
        Parameters:
        dm - the distance metric to use
        batchSize - the mini-batch size
        iterations - the number of mini batches to perform
      • MiniBatchKMeans

        public MiniBatchKMeans(DistanceMetric dm,
                               int batchSize,
                               int iterations,
                               SeedSelectionMethods.SeedSelection seedSelection)
        Creates a new Mini-Batch k-Means object
        Parameters:
        dm - the distance metric to use
        batchSize - the mini-batch size
        iterations - the number of mini batches to perform
        seedSelection - the seed selection algorithm to initiate clustering
      • MiniBatchKMeans

        public MiniBatchKMeans(MiniBatchKMeans toCopy)
        Copy constructor
        Parameters:
        toCopy - the object to copy
    • Method Detail

      • setStoreMeans

        public void setStoreMeans(boolean storeMeans)
        If set to true the computed means will be stored after clustering is completed, and can then be retrieved using getMeans().
        Parameters:
        storeMeans - true if the means should be stored for later, false to discard them once clustering is complete.
      • getMeans

        public java.util.List<Vec> getMeans()
        Returns the raw list of means that were used for each class.
        Returns:
        the list of means for each class
      • setDistanceMetric

        public void setDistanceMetric(DistanceMetric dm)
        Sets the distance metric used for determining the nearest cluster center
        Parameters:
        dm - the distance metric to use
      • getDistanceMetric

        public DistanceMetric getDistanceMetric()
        Returns the distance metric used for determining the nearest cluster center
        Returns:
        the distance metric in use
      • setBatchSize

        public void setBatchSize(int batchSize)
        Sets the batch size to use at each iteration. Increasing the batch size can improve the resulting clustering, but increases computational cost at each iteration.
        If the batch size is set equal to or larger than data set size, it reduces to the naive k-means algorithm.
        Parameters:
        batchSize - the number of points to use at each iteration
      • getBatchSize

        public int getBatchSize()
        Returns the batch size used at each iteration
        Returns:
        the batch size in use
      • setIterations

        public void setIterations(int iterations)
        Sets the number of mini-batch iterations to perform
        Parameters:
        iterations - the number of algorithm iterations to perform
      • getIterations

        public int getIterations()
        Returns the number of mini-batch iterations used
        Returns:
        the number of algorithm iterations that will be used
      • setSeedSelection

        public void setSeedSelection(SeedSelectionMethods.SeedSelection seedSelection)
        Sets the method of selecting the initial data points to seed the clustering algorithm.
        Parameters:
        seedSelection - the seed selection algorithm to use
      • getSeedSelection

        public SeedSelectionMethods.SeedSelection getSeedSelection()
        Returns the method of seed selection to use
        Returns:
        the method of seed selection to use
      • cluster

        public int[] cluster(DataSet dataSet,
                             int[] designations)
        Description copied from interface: Clusterer
        Performs clustering on the given data set. Parameters may be estimated by the method, or other heuristics performed.
        Parameters:
        dataSet - the data set to perform clustering on
        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:
        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: Clusterer
        Performs clustering on the given data set. Parameters may be estimated by the method, or other heuristics performed.
        Parameters:
        dataSet - the data set to perform clustering on
        parallel - true if multiple threads should be used to perform clustering. false if 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)
      • cluster

        public int[] cluster(DataSet dataSet,
                             int lowK,
                             int highK,
                             boolean parallel,
                             int[] designations)

DataMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.