idnaive
v0.0.5
Published
A Simple Node.js Naive Bayes Library.
Downloads
1
Readme
Idnaive
Idnaive is A Simple Node.js Naive Bayes Library.
✅ Multilanguage Stemming (Indonesia + English)
✅ Out String Filter
✅ Punctuation Filter
✅ Fix Zero-Frequency Problem
Installation
npm install idnaive
Usage
const NaiveBayes = require("idnaive");
const naiveBayes = new NaiveBayes("en");
const datasets = [
["You're doing good and expressive", "positive"],
["You're doing wow and nice", "positive"],
["What is this? very waste of time, and bad", "negative"],
];
naiveBayes.learn(...datasets);
let result = naiveBayes.classify(
"This is bad, and you should try better because it waste my time"
);
console.log(result);
Datasets example :
| Data | Label | | ----------- | ------- | | Hello World | Inggris | | Hello World | Inggris | | Hello World | Arab | | Kun Fayakun | Arab |
Input Data : Aku suka makan hello world
Calculation
Label | Inggris = 2/4
Label | Arab = 2/4
Hello World | Inggris = 2/2
Hello World | Arab = 1/2
P | Inggris = 2/4 x 2/2 = 0.5
P | Arab = 2/4 X 1/2 = 0.25
Parameters
- new NaiveBayes(languageCode)
- languageCode: languageCode determines what language used for stemming by the language code. currently idnaive supports
id (Indonesia)
anden (English)
.
- languageCode: languageCode determines what language used for stemming by the language code. currently idnaive supports
License
Idnaive licensed by MIT License
Contribute
Before contributing, please read the following CODE_OF_CONDUCT.md and CONTRIBUTING.md.
Credits
Credits to their amazing open source: