Class: NaiveBayes

eclairjs/mllib/classification.NaiveBayes

new NaiveBayes(lambda)

Trains a Naive Bayes model given an RDD of `(label, features)` pairs. This is the Multinomial NB ([[http://tinyurl.com/lsdw6p]]) which can handle all kinds of discrete data. For example, by converting documents into TF-IDF vectors, it can be used for document classification. By making every vector a 0-1 vector, it can also be used as Bernoulli NB ([[http://tinyurl.com/p7c96j6]]). The input feature values must be nonnegative.
Parameters:
Name Type Description
lambda number
Source:

Methods

(static) train(input, lambdaopt, modelTypeopt) → {module:eclairjs/mllib/classification.NaiveBayesModel}

Trains a Naive Bayes model given an RDD of `(label, features)` pairs. The model type can be set to either Multinomial NB ([[http://tinyurl.com/lsdw6p]]) or Bernoulli NB ([[http://tinyurl.com/p7c96j6]]). The Multinomial NB can handle discrete count data and can be called by setting the model type to "multinomial". For example, it can be used with word counts or TF_IDF vectors of documents. The Bernoulli model fits presence or absence (0-1) counts. By making every vector a 0-1 vector and setting the model type to "bernoulli", the fits and predicts as Bernoulli NB.
Parameters:
Name Type Attributes Description
input module:eclairjs/rdd.RDD RDD of `(label, array of features)` pairs. Every vector should be a frequency vector or a count vector.
lambda float <optional>
The smoothing parameter
modelType string <optional>
The type of NB model to fit from the enumeration NaiveBayesModels, can be multinomial or bernoulli
Source:
Returns:
Type
module:eclairjs/mllib/classification.NaiveBayesModel

getLambda() → {Promise.<number>}

Source:
Returns:
Type
Promise.<number>

getModelType() → {Promise.<string>}

Source:
Returns:
Type
Promise.<string>

run(data) → {module:eclairjs/mllib/classification.NaiveBayesModel}

Run the algorithm with the configured parameters on an input RDD of LabeledPoint entries.
Parameters:
Name Type Description
data module:eclairjs/rdd.RDD RDD of LabeledPoint.
Source:
Returns:
Type
module:eclairjs/mllib/classification.NaiveBayesModel

setLambda(lambda) → {module:eclairjs/mllib/classification.NaiveBayes}

Parameters:
Name Type Description
lambda number
Source:
Returns:
Type
module:eclairjs/mllib/classification.NaiveBayes

setModelType(modelType) → {module:eclairjs/mllib/classification.NaiveBayes}

Set the model type using a string (case-sensitive). Supported options: "multinomial" (default) and "bernoulli".
Parameters:
Name Type Description
modelType string
Source:
Returns:
Type
module:eclairjs/mllib/classification.NaiveBayes