|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Object org.apache.spark.mllib.clustering.KMeansModel
public class KMeansModel
A clustering model for K-means. Each point belongs to the cluster with the closest center.
Constructor Summary | |
---|---|
KMeansModel(Iterable<Vector> centers)
A Java-friendly constructor that takes an Iterable of Vectors. |
|
KMeansModel(Vector[] clusterCenters)
|
Method Summary | |
---|---|
Vector[] |
clusterCenters()
|
double |
computeCost(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. |
int |
k()
Total number of clusters. |
static KMeansModel |
load(SparkContext sc,
String path)
|
JavaRDD<Integer> |
predict(JavaRDD<Vector> points)
Maps given points to their cluster indices. |
RDD<Object> |
predict(RDD<Vector> points)
Maps given points to their cluster indices. |
int |
predict(Vector point)
Returns the cluster index that a given point belongs to. |
void |
save(SparkContext sc,
String path)
Save this model to the given path. |
Methods inherited from class Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.apache.spark.mllib.pmml.PMMLExportable |
---|
toPMML, toPMML, toPMML, toPMML, toPMML |
Constructor Detail |
---|
public KMeansModel(Vector[] clusterCenters)
public KMeansModel(Iterable<Vector> centers)
Method Detail |
---|
public static KMeansModel load(SparkContext sc, String path)
public Vector[] clusterCenters()
public int k()
public int predict(Vector point)
public RDD<Object> predict(RDD<Vector> points)
public JavaRDD<Integer> predict(JavaRDD<Vector> points)
public double computeCost(RDD<Vector> data)
data
- (undocumented)
public void save(SparkContext sc, String path)
Saveable
This saves: - human-readable (JSON) model metadata to path/metadata/ - Parquet formatted data to path/data/
The model may be loaded using Loader.load
.
save
in interface Saveable
sc
- Spark context used to save model data.path
- Path specifying the directory in which to save this model.
If the directory already exists, this method throws an exception.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |