GaussianMixtureModel (Spark 3.5.5 JavaDoc) (original) (raw)
Object
- org.apache.spark.mllib.clustering.GaussianMixtureModel
All Implemented Interfaces:
java.io.Serializable, Saveable
public class GaussianMixtureModel
extends Object
implements scala.Serializable, Saveable
Multivariate Gaussian Mixture Model (GMM) consisting of k Gaussians, where points are drawn from each Gaussian i=1..k with probability w(i); mu(i) and sigma(i) are the respective mean and covariance for each Gaussian distribution i=1..k.
param: weights Weights for each Gaussian distribution in the mixture, where weights(i) is the weight for Gaussian i, and weights.sum == 1 param: gaussians Array of MultivariateGaussian where gaussians(i) represents the Multivariate Gaussian (Normal) Distribution for Gaussian i
See Also:
Serialized Form
Constructor Summary
Constructors
Constructor and Description GaussianMixtureModel(double[] weights,MultivariateGaussian[] gaussians) Method Summary
All Methods Static Methods Instance Methods Concrete Methods
Modifier and Type Method and Description MultivariateGaussian[] gaussians() int k() Number of gaussians in mixture static GaussianMixtureModel load(SparkContext sc, String path) JavaRDD predict(JavaRDD<Vector> points) Java-friendly version of predict() RDD predict(RDD<Vector> points) Maps given points to their cluster indices. int predict(Vector point) Maps given point to its cluster index. RDD<double[]> predictSoft(RDD<Vector> points) Given the input vectors, return the membership value of each vector to all mixture components. double[] predictSoft(Vector point) Given the input vector, return the membership values to all mixture components. void save(SparkContext sc, String path) Save this model to the given path. double[] weights() * ### Methods inherited from class Object `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`
Constructor Detail
* #### GaussianMixtureModel public GaussianMixtureModel(double[] weights, [MultivariateGaussian](../../../../../org/apache/spark/mllib/stat/distribution/MultivariateGaussian.html "class in org.apache.spark.mllib.stat.distribution")[] gaussians)
Method Detail
* #### load public static [GaussianMixtureModel](../../../../../org/apache/spark/mllib/clustering/GaussianMixtureModel.html "class in org.apache.spark.mllib.clustering") load([SparkContext](../../../../../org/apache/spark/SparkContext.html "class in org.apache.spark") sc, String path) * #### weights public double[] weights() * #### gaussians public [MultivariateGaussian](../../../../../org/apache/spark/mllib/stat/distribution/MultivariateGaussian.html "class in org.apache.spark.mllib.stat.distribution")[] gaussians() * #### save public void save([SparkContext](../../../../../org/apache/spark/SparkContext.html "class in org.apache.spark") sc, String path) Description copied from interface: `[Saveable](../../../../../org/apache/spark/mllib/util/Saveable.html#save-org.apache.spark.SparkContext-java.lang.String-)` Save 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`. Specified by: `[save](../../../../../org/apache/spark/mllib/util/Saveable.html#save-org.apache.spark.SparkContext-java.lang.String-)` in interface `[Saveable](../../../../../org/apache/spark/mllib/util/Saveable.html "interface in org.apache.spark.mllib.util")` Parameters: `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. * #### k public int k() Number of gaussians in mixture Returns: (undocumented) * #### predict public [RDD](../../../../../org/apache/spark/rdd/RDD.html "class in org.apache.spark.rdd")<Object> predict([RDD](../../../../../org/apache/spark/rdd/RDD.html "class in org.apache.spark.rdd")<[Vector](../../../../../org/apache/spark/mllib/linalg/Vector.html "interface in org.apache.spark.mllib.linalg")> points) Maps given points to their cluster indices. Parameters: `points` \- (undocumented) Returns: (undocumented) * #### predict public int predict([Vector](../../../../../org/apache/spark/mllib/linalg/Vector.html "interface in org.apache.spark.mllib.linalg") point) Maps given point to its cluster index. Parameters: `point` \- (undocumented) Returns: (undocumented) * #### predict public [JavaRDD](../../../../../org/apache/spark/api/java/JavaRDD.html "class in org.apache.spark.api.java")<Integer> predict([JavaRDD](../../../../../org/apache/spark/api/java/JavaRDD.html "class in org.apache.spark.api.java")<[Vector](../../../../../org/apache/spark/mllib/linalg/Vector.html "interface in org.apache.spark.mllib.linalg")> points) Java-friendly version of `predict()` Parameters: `points` \- (undocumented) Returns: (undocumented) * #### predictSoft public [RDD](../../../../../org/apache/spark/rdd/RDD.html "class in org.apache.spark.rdd")<double[]> predictSoft([RDD](../../../../../org/apache/spark/rdd/RDD.html "class in org.apache.spark.rdd")<[Vector](../../../../../org/apache/spark/mllib/linalg/Vector.html "interface in org.apache.spark.mllib.linalg")> points) Given the input vectors, return the membership value of each vector to all mixture components. Parameters: `points` \- (undocumented) Returns: (undocumented) * #### predictSoft public double[] predictSoft([Vector](../../../../../org/apache/spark/mllib/linalg/Vector.html "interface in org.apache.spark.mllib.linalg") point) Given the input vector, return the membership values to all mixture components. Parameters: `point` \- (undocumented) Returns: (undocumented)