public class KMeansModel extends java.lang.Object implements Saveable, scala.Serializable, PMMLExportable
Constructor and Description |
---|
KMeansModel(java.lang.Iterable<Vector> centers)
A Java-friendly constructor that takes an Iterable of Vectors.
|
KMeansModel(Vector[] clusterCenters) |
Modifier and Type | Method and Description |
---|---|
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.
|
protected java.lang.String |
formatVersion()
Current version of model save/load format.
|
int |
k()
Total number of clusters.
|
static KMeansModel |
load(SparkContext sc,
java.lang.String path) |
JavaRDD<java.lang.Integer> |
predict(JavaRDD<Vector> points)
Maps given points to their cluster indices.
|
RDD<java.lang.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,
java.lang.String path)
Save this model to the given path.
|
public KMeansModel(Vector[] clusterCenters)
public KMeansModel(java.lang.Iterable<Vector> centers)
centers
- (undocumented)public static KMeansModel load(SparkContext sc, java.lang.String path)
public Vector[] clusterCenters()
public int k()
public int predict(Vector point)
point
- (undocumented)public RDD<java.lang.Object> predict(RDD<Vector> points)
points
- (undocumented)public JavaRDD<java.lang.Integer> predict(JavaRDD<Vector> points)
points
- (undocumented)public double computeCost(RDD<Vector> data)
data
- (undocumented)public void save(SparkContext sc, java.lang.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
.
protected java.lang.String formatVersion()
Saveable
formatVersion
in interface Saveable