Skip to content

BayesianClassifier

Defined in: src/bayesian_classifier.js:21

Bayesian Classifier

This is a naïve bayesian classifier that takes singly-nested objects.

var bayes = new BayesianClassifier();
bayes.train({
species: 'Cat'
}, 'animal');
var result = bayes.score({
species: 'Cat'
})
// result
// {
// animal: 1
// }

new BayesianClassifier(): BayesianClassifier

Defined in: src/bayesian_classifier.js:24

BayesianClassifier

data: object

Defined in: src/bayesian_classifier.js:29


totalCount: number

Defined in: src/bayesian_classifier.js:27

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

any

an item in the same format as with train

any

of probabilities that this item belongs to a given category.


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.

any

an object with singly-deep properties

string

the category this item belongs to

undefined

adds the item to the classifier