|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Object org.apache.spark.mllib.classification.NaiveBayesModel
public class NaiveBayesModel
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"
Method Summary | |
---|---|
double[] |
labels()
|
static NaiveBayesModel |
load(SparkContext sc,
String path)
|
String |
modelType()
|
double[] |
pi()
|
RDD<Object> |
predict(RDD<Vector> testData)
Predict values for the given data set using the model trained. |
double |
predict(Vector testData)
Predict values for a single data point using the model trained. |
void |
save(SparkContext sc,
String path)
Save this model to the given path. |
double[][] |
theta()
|
Methods inherited from class Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.apache.spark.mllib.classification.ClassificationModel |
---|
predict |
Method Detail |
---|
public static NaiveBayesModel load(SparkContext sc, String path)
public double[] labels()
public double[] pi()
public double[][] theta()
public String modelType()
public RDD<Object> predict(RDD<Vector> testData)
ClassificationModel
predict
in interface ClassificationModel
testData
- RDD representing data points to be predicted
public double predict(Vector testData)
ClassificationModel
predict
in interface ClassificationModel
testData
- array representing a single data point
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 |