Package pyspark :: Package mllib :: Module clustering :: Class KMeansModel
[frames] | no frames]

Class KMeansModel

source code

object --+
         |
        KMeansModel

A clustering model derived from the k-means method.

>>> data = array([0.0,0.0, 1.0,1.0, 9.0,8.0, 8.0,9.0]).reshape(4,2)
>>> clusters = KMeans.train(sc.parallelize(data), 2, maxIterations=10, runs=30, initializationMode="random")
>>> clusters.predict(array([0.0, 0.0])) == clusters.predict(array([1.0, 1.0]))
True
>>> clusters.predict(array([8.0, 9.0])) == clusters.predict(array([9.0, 8.0]))
True
>>> clusters = KMeans.train(sc.parallelize(data), 2)
Instance Methods
 
__init__(self, centers_)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
predict(self, x)
Find the cluster to which x belongs in this model.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties

Inherited from object: __class__

Method Details

__init__(self, centers_)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)