Class BIRCHKMeansPlusPlus


  • public class BIRCHKMeansPlusPlus
    extends java.lang.Object
    K-Means++-like initialization for BIRCH k-means; this cannot be used to initialize regular k-means, use KMeansPlusPlus instead.
    Since:
    0.8.0
    Author:
    Andreas Lang
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  BIRCHKMeansPlusPlus.Par
      Parameterization class.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected RandomFactory random
      Random generator
      protected double[] weights
      Weights
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private double distance​(double[] ds, double[] ds2)
      Calculates distance between two vectors.
      private double initialWeights​(double[] first, double[][] x)
      Initialize the weight list.
      double[][] run​(double[][] x, int k)
      Perform k-means++ initialization.
      private double updateWeights​(double[] latest, double[][] x)
      Update the weight list.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • weights

        protected double[] weights
        Weights
    • Constructor Detail

      • BIRCHKMeansPlusPlus

        public BIRCHKMeansPlusPlus​(RandomFactory rnd)
        Constructor.
        Parameters:
        rnd - Random generator.
    • Method Detail

      • run

        public double[][] run​(double[][] x,
                              int k)
        Perform k-means++ initialization.
        Parameters:
        x - Input vectors.
        k - K
        Returns:
        Initial cluster centers
      • initialWeights

        private double initialWeights​(double[] first,
                                      double[][] x)
        Initialize the weight list.
        Parameters:
        first - Id of first mean.
        x - Input data.
        Returns:
        Sum of weights
      • distance

        private double distance​(double[] ds,
                                double[] ds2)
        Calculates distance between two vectors.
        Parameters:
        ds - First Vector
        ds2 - Second Vector
        Returns:
        Vector
      • updateWeights

        private double updateWeights​(double[] latest,
                                     double[][] x)
        Update the weight list.
        Parameters:
        latest - Latest center
        Returns:
        Weight sum