Class NaiveBayesModel
Object
org.apache.spark.mllib.classification.NaiveBayesModel
- All Implemented Interfaces:
- Serializable,- ClassificationModel,- Saveable
Model for Naive Bayes Classifiers.
 
param: labels list of labels param: pi log of class priors, whose dimension is C, number of labels param: theta log of class conditional probabilities, whose dimension is C-by-D, where D is number of features param: modelType The type of NB model to fit can be "multinomial" or "bernoulli"
- See Also:
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic classstatic class
- 
Method SummaryModifier and TypeMethodDescriptiondouble[]labels()static NaiveBayesModelload(SparkContext sc, String path) double[]pi()doublePredict values for a single data point using the model trained.Predict values for the given data set using the model trained.predictProbabilities(Vector testData) Predict posterior class probabilities for a single data point using the model trained.predictProbabilities(RDD<Vector> testData) Predict values for the given data set using the model trained.voidsave(SparkContext sc, String path) Save this model to the given path.double[][]theta()Methods inherited from class java.lang.Objectequals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.spark.mllib.classification.ClassificationModelpredict
- 
Method Details- 
load
- 
labelspublic double[] labels()
- 
pipublic double[] pi()
- 
thetapublic double[][] theta()
- 
modelType
- 
predictDescription copied from interface:ClassificationModelPredict values for the given data set using the model trained.- Specified by:
- predictin interface- ClassificationModel
- Parameters:
- testData- RDD representing data points to be predicted
- Returns:
- an RDD[Double] where each entry contains the corresponding prediction
 
- 
predictDescription copied from interface:ClassificationModelPredict values for a single data point using the model trained.- Specified by:
- predictin interface- ClassificationModel
- Parameters:
- testData- array representing a single data point
- Returns:
- predicted category from the trained model
 
- 
predictProbabilitiesPredict values for the given data set using the model trained.- Parameters:
- testData- RDD representing data points to be predicted
- Returns:
- an RDD[Vector] where each entry contains the predicted posterior class probabilities, in the same order as class labels
 
- 
predictProbabilitiesPredict posterior class probabilities for a single data point using the model trained.- Parameters:
- testData- array representing a single data point
- Returns:
- predicted posterior class probabilities from the trained model, in the same order as class labels
 
- 
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.
 
-