public class KMeansModel extends Object implements Saveable, scala.Serializable, PMMLExportable
Modifier and Type | Class and Description |
---|---|
static class |
KMeansModel.SaveLoadV1_0$ |
Constructor and Description |
---|
KMeansModel(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.
|
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.
|
static String |
toPMML() |
static void |
toPMML(java.io.OutputStream outputStream) |
static void |
toPMML(SparkContext sc,
String path) |
static void |
toPMML(String localPath) |
public KMeansModel(Vector[] clusterCenters)
public KMeansModel(Iterable<Vector> centers)
centers
- (undocumented)public static KMeansModel load(SparkContext sc, String path)
public static void toPMML(String localPath)
public static void toPMML(SparkContext sc, String path)
public static void toPMML(java.io.OutputStream outputStream)
public static String toPMML()
public Vector[] clusterCenters()
public int k()
public int predict(Vector point)
point
- (undocumented)public RDD<Object> predict(RDD<Vector> points)
points
- (undocumented)public JavaRDD<Integer> predict(JavaRDD<Vector> points)
points
- (undocumented)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
.