Idnaive is A Simple Node.js Naive Bayes Library.
✅ Multilanguage Stemming (Indonesia + English)
✅ Out String Filter
✅ Punctuation Filter
✅ Fix Zero-Frequency Problem
npm install idnaive
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);
Data | Label |
---|---|
Hello World | Inggris |
Hello World | Inggris |
Hello World | Arab |
Kun Fayakun | Arab |
Input Data : Aku suka makan hello world
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
- 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
Idnaive licensed by MIT License
Before contributing, please read the following CODE_OF_CONDUCT.md and CONTRIBUTING.md.
Credits to their amazing open source: