How it works...

First, we need to import the clustering submodule of MLlib. Just like before, we first create the clustering estimator object, KMeans. The .train(...) method requires two parameters: the RDD we want to use to find the clusters in, and the number of clusters we expect. We also chose to randomly initialize the centroids of the clusters by specifying initializationMode; the default for this one is k-means||. Other parameters include:

  • maxIterations specifies after how many iterations the estimation should stop; the default is 100
  • initializationSteps is only useful if the default initialization mode is used; the default for this parameter is 2
  • epsilon is a stopping criteria—if all the centers of the centroids move (in terms of the Euclidean distance) less than this, the iterations stop; the default is 0.0001
  • initialModel allows you to specify the centers previously estimated in the form of KMeansModel; the default is None
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset