Git Product home page Git Product logo

naive-bayes's Introduction

Naive Bayes

NPM version build status David deps npm download

Naive bayes classifier.

Methods

new NaiveBayes()

Constructor that takes no arguments.

Example

var nb = new NaiveBayes();

train(trainingSet, predictions)

Train the Naive Bayes model to the given training set and predictions

Arguments

  • trainingSet - A matrix of the training set.
  • trainingLabels - An array of value for each case in the training set.

Example

var cases = [[6,148,72,35,0,33.6,0.627,5],
             [1.50,85,66.5,29,0,26.6,0.351,31],
             [8,183,64,0,0,23.3,0.672,32],
             [0.5,89,65.5,23,94,28.1,0.167,21],
             [0,137,40,35,168,43.1,2.288,33]];
var predictions = [1, 0, 1, 0, 1];

nb.train(trainingSet, predictions);

predict(dataset)

Predict the values of the dataset.

Arguments

  • dataset - A matrix that contains the dataset.

Example

var dataset = [[6,148,72,35,0,33.6,0.627,5],
               [1.50,85,66.5,29,0,26.6,0.351,31]];

var ans = nb.predict(dataset);

export()

Exports the actual Naive Bayes model to an Javascript Object.

load(model)

Returns a new Naive Bayes Classifier with the given model.

Arguments

  • model - Javascript Object generated from export() function.

Authors

License

MIT

naive-bayes's People

Contributors

targos avatar maasencioh avatar hseung avatar jeffersonh44 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.