Class KMeansProcessor<V extends NumberVector>

  • All Implemented Interfaces:
    Processor

    public class KMeansProcessor<V extends NumberVector>
    extends java.lang.Object
    implements Processor
    Parallel k-means implementation.
    Since:
    0.7.0
    Author:
    Erich Schubert
    • Field Detail

      • means

        double[][] means
        Mean vectors.
      • centroids

        double[][] centroids
        Updated cluster centroids
      • sizes

        int[] sizes
        (Partial) cluster sizes
      • varsum

        double[] varsum
        Variance sum.
      • changed

        boolean changed
        Whether the assignment changed during the last iteration.
    • Constructor Detail

      • KMeansProcessor

        public KMeansProcessor​(Relation<V> relation,
                               NumberVectorDistance<? super V> distance,
                               WritableIntegerDataStore assignment,
                               double[] varsum)
        Constructor.
        Parameters:
        relation - Data relation
        distance - Distance function
        assignment - Cluster assignment
        varsum - Variance sums
    • Method Detail

      • changed

        public boolean changed()
        Get the "has changed" value.
        Returns:
        Changed flag.
      • nextIteration

        public void nextIteration​(double[][] means)
        Initialize for a new iteration.
        Parameters:
        means - New means.
      • instantiate

        public KMeansProcessor.Instance<V> instantiate​(Executor exectutor)
        Description copied from interface: Processor
        Create an instance. May be called multiple times, for example for multiple threads.
        Specified by:
        instantiate in interface Processor
        Parameters:
        exectutor - Job executor
        Returns:
        Instance
      • getMeans

        public double[][] getMeans()
        Get the new means.
        Returns:
        New means