Class KMeans

    • Field Detail

      • k

        protected int k
        The number of cluster the data will be partitioned into
      • distanceFunction

        protected DistanceFunction distanceFunction
        Function to calculate distance between individual data points
      • lastIterationCount

        protected int lastIterationCount
    • Constructor Detail

      • KMeans

        public KMeans​(int clusters)
        Create a KMeans clusterer with k clusters and EuclideanDistance.
        Parameters:
        clusters - the number of cluster to partition the data into
      • KMeans

        public KMeans​(int clusters,
                      DistanceFunction distanceFunction)
        Create a KMeans clusterer
        Parameters:
        clusters - the number of cluster to partition the data into
        distanceFunction - the distanceFunction used to compute the distance between data points
    • Method Detail

      • computeStartingClusters

        protected DoubleSummaryStatistics[][] computeStartingClusters​(double[][] data,
                                                                      int k,
                                                                      int dataDimension)
      • computeKMeans

        protected void computeKMeans​(DoubleSummaryStatistics[][] clusterMeans,
                                     double[][] data,
                                     int[] cluster,
                                     int dataDimension)
      • iterations

        public int iterations()
        Returns:
        the number of iterations used to cluster the data