Documentation of 'ca.pfv.spmf.algorithms.clustering.kmeans.AlgoKMeans' Java class
AlgoKMeans
ca.pfv.spmf.algorithms.clustering.kmeans

Class AlgoKMeans



  • public class AlgoKMeans
    extends java.lang.Object
    An implementation of the K-means algorithm (J. MacQueen, 1967).

    The K-means algorithm steps are (text from Wikipedia) : 1) Choose the number of clusters, k. * 2) Randomly generate k clusters and determine the cluster centers, or directly generate k random points as cluster centers. 3) Assign each point to the nearest cluster center. 4) Recompute the new cluster centers. 5) Repeat the two previous steps until some convergence criterion is met (usually that the assignment hasn't changed).
    • Constructor Summary

      Constructors 
      Constructor and Description
      AlgoKMeans()
      Default constructor
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      void printStatistics()
      Print statistics of the latest execution to System.out.
      java.util.List<Cluster> runAlgorithm(java.lang.String inputFile, int k)
      Run the K-Means algorithm
      void saveToFile(java.lang.String output)
      Save the clusters to an output file
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AlgoKMeans

        public AlgoKMeans()
        Default constructor
    • Method Detail

      • runAlgorithm

        public java.util.List<Cluster> runAlgorithm(java.lang.String inputFile,
                                                    int k)
                                             throws java.lang.NumberFormatException,
                                                    java.io.IOException
        Run the K-Means algorithm
        Parameters:
        inputFile - an input file path containing a list of vectors of double values
        k - the parameter k
        Returns:
        a list of clusters (some of them may be empty)
        Throws:
        java.io.IOException - exception if an error while writing the file occurs
        java.lang.NumberFormatException
      • printStatistics

        public void printStatistics()
        Print statistics of the latest execution to System.out.
      • saveToFile

        public void saveToFile(java.lang.String output)
                        throws java.io.IOException
        Save the clusters to an output file
        Parameters:
        output - the output file path
        Throws:
        java.io.IOException - exception if there is some writing error.

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.