BayesianClassifier
Defined in: src/bayesian_classifier.js:21
This is a naïve bayesian classifier that takes singly-nested objects.
Example
Section titled “Example”var bayes = new BayesianClassifier();bayes.train({ species: 'Cat'}, 'animal');var result = bayes.score({ species: 'Cat'})// result// {// animal: 1// }Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new BayesianClassifier():
BayesianClassifier
Defined in: src/bayesian_classifier.js:24
Returns
Section titled “Returns”BayesianClassifier
Properties
Section titled “Properties”data:
object
Defined in: src/bayesian_classifier.js:29
totalCount
Section titled “totalCount”totalCount:
number
Defined in: src/bayesian_classifier.js:27
Methods
Section titled “Methods”score()
Section titled “score()”score(
item):any
Defined in: src/bayesian_classifier.js:75
Generate a score of how well this item matches all possible categories based on its attributes
Parameters
Section titled “Parameters”any
an item in the same format as with train
Returns
Section titled “Returns”any
of probabilities that this item belongs to a given category.
train()
Section titled “train()”train(
item,category):undefined
Defined in: src/bayesian_classifier.js:40
Train the classifier with a new item, which has a single dimension of Javascript literal keys and values.
Parameters
Section titled “Parameters”any
an object with singly-deep properties
category
Section titled “category”string
the category this item belongs to
Returns
Section titled “Returns”undefined
adds the item to the classifier
