Class KMeansModel
Object
org.apache.spark.mllib.clustering.KMeansModel
- All Implemented Interfaces:
- Serializable,- PMMLExportable,- Saveable
- Direct Known Subclasses:
- StreamingKMeansModel
A clustering model for K-means. Each point belongs to the cluster with the closest center.
- See Also:
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic classstatic classstatic class
- 
Constructor SummaryConstructorsConstructorDescriptionKMeansModel(Iterable<Vector> centers) A Java-friendly constructor that takes an Iterable of Vectors.KMeansModel(Vector[] clusterCenters) KMeansModel(Vector[] clusterCenters, String distanceMeasure, double trainingCost, int numIter) 
- 
Method SummaryModifier and TypeMethodDescriptionVector[]doublecomputeCost(RDD<Vector> data) Return the K-means cost (sum of squared distances of points to their nearest center) for this model on the given data.intk()Total number of clusters.static KMeansModelload(SparkContext sc, String path) Maps given points to their cluster indices.intReturns the cluster index that a given point belongs to.Maps given points to their cluster indices.voidsave(SparkContext sc, String path) Save this model to the given path.double
- 
Constructor Details- 
KMeansModel
- 
KMeansModel
- 
KMeansModelA Java-friendly constructor that takes an Iterable of Vectors.- Parameters:
- centers- (undocumented)
 
 
- 
- 
Method Details- 
load
- 
clusterCenters
- 
distanceMeasure
- 
trainingCostpublic double trainingCost()
- 
kpublic int k()Total number of clusters.- Returns:
- (undocumented)
 
- 
predictReturns the cluster index that a given point belongs to.- Parameters:
- point- (undocumented)
- Returns:
- (undocumented)
 
- 
predictMaps given points to their cluster indices.- Parameters:
- points- (undocumented)
- Returns:
- (undocumented)
 
- 
predictMaps given points to their cluster indices.- Parameters:
- points- (undocumented)
- Returns:
- (undocumented)
 
- 
computeCostReturn the K-means cost (sum of squared distances of points to their nearest center) for this model on the given data.- Parameters:
- data- (undocumented)
- Returns:
- (undocumented)
 
- 
saveDescription copied from interface:SaveableSave this model to the given path.This saves: - human-readable (JSON) model metadata to path/metadata/ - Parquet formatted data to path/data/ The model may be loaded using Loader.load.
 
-