Skip to content

Ocelmot/Classifier

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Classifier

Classifier is a simple naive Bayes classifier module for Node.

Getting started

To install

npm install --save https://github.com/Ocelmot/Classifier.git

To require

const Classifier = require('Classifier');

Usage

Initialization

First generate a classifier instance like so.

var c = Classifier();

Generate Evidence

Once you have a classifier instance you need to start feeding it evidence. In order to do this you must create an evidence object.

var e = c.Evidence();

You can add information to the evidence object with the add method.

e.add('sale');

Training the Classifier

If you are training the classifier, you must also add the category to the evidence.

e.setCategory('spam');

To train the classifier, pass the evidence object to the classifier's train method.

c.train(e);

Classify Evidence

Once you have finished training the classifier, you can classify evidence by passing it to the classify method.

var result = c.classify(e);
console.log(result)

The classify method returns the category name as a string.

Misc

  • You may repeat the evidence creation, training, and classification as many times as you need.
  • You may create multiple classifiers. They will train and classify independently.
  • The classifier will automatically add categories as it sees evidence of them.

About

A simple Bayes-Classifier module for Node

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published