Naive Bayes classifier
Description
A simple node.js module for Naive Bayes classifier.
It works also with continuous variables and can return results in log scale. There is also a function to clean the dataset.
Installation
$ npm install naivebayes-predictor
Example
'use strict'; // Require Naive Bayes moduleconst NaiveBayes = ; // Get a datasetlet dataset = skill: 'mathematics' industry: 'finance' age: 18 score: 5 verified: 0 skill: 'mathematics' industry: 'finance' age: 18 score: 6 verified: 0 skill: 'mathematics' industry: 'business' age: 18 score: 8 verified: 1 skill: 'mathematics' industry: 'finance' age: 18 score: 7 verified: 0 skill: 'economy' industry: 'finance' age: 30 score: 4 verified: 1 skill: 'economy' industry: 'sales' age: 32 score: 3 verified: 0 skill: 'economy' industry: 'business' age: 31 score: 3 verified: 1 skill: 'economy' industry: 'business' age: 34 score: 4 verified: 1 ...; // Make continuous variables discrete detecting range intervals inside every single variabledataset = naive; // Train the modelnaive; // Compute the resultsnaive;// Distribution in scale from 0.0 to 1.0 // Show the results about "skill" featureconsole;// { mathematics: 0.017578125, economy: 0.0029296875 } // Clean the model and the resultsnaive; // Use another datasetdataset = ... ... etc; // Optional: clean the dataset from some variabledataset = naive; // Make continuous variables discrete detecting range intervals inside every single variabledataset = naive; // Train the modelnaive; // Compute the resultsnaive;// Distribution in scale from 0.0 to 1.0 // Compute the results in log scalenaive;// More negative is the value more small the probability// { '0': -3361.759725902712, '1': -2087.72499485088 } // Show the results about "Survived" featureconsole;