Constructor for the Gaussian Naive Bayes classifier, the parameters here is just for loading purposes.

new constructor(reload: boolean, model: object)
Parameters
reload (boolean)
model (object)

function that predicts each row of the dataset (must be a matrix).

predict(dataset: (Matrix | Array)): Array
Parameters
dataset ((Matrix | Array))
Returns
Array:

Function that export the NaiveBayes model.

toJSON(): object
Returns
object:

Function that trains the classifier with a matrix that represents the training set and an array that represents the label of each row in the training set. the labels must be numbers between 0 to n-1 where n represents the number of classes.

WARNING: in the case that one class, all the cases in one or more features have the same value, the Naive Bayes classifier will not work well.

train(trainingSet: (Matrix | Array), trainingLabels: (Matrix | Array))
Parameters
trainingSet ((Matrix | Array))
trainingLabels ((Matrix | Array))

Function that create a GaussianNB classifier with the given model.

load(model: object): GaussianNB
Parameters
model (object)
Returns
GaussianNB:

Constructor for Multinomial Naive Bayes, the model parameter is for load purposes.

new constructor(model: object)
Parameters
model (object) for load purposes.

Retrieves the predictions for the dataset with the current model.

predict(dataset: (Matrix | Array)): Array
Parameters
dataset ((Matrix | Array))
Returns
Array: predictions from the dataset.

Function that saves the current model.

toJSON(): object
Returns
object: model in JSON format.

Train the classifier with the current training set and labels, the labels must be numbers between 0 and n.

train(trainingSet: (Matrix | Array), trainingLabels: Array)
Parameters
trainingSet ((Matrix | Array))
trainingLabels (Array)

Creates a new MultinomialNB from the given model

load(model: object): MultinomialNB
Parameters
model (object)
Returns
MultinomialNB: