Configurable Naive Bayes Classifier for text with cross-validation support
Classify text, analyse sentiments, recognize user intents for chatbot using
wink-naive-bayes-text-classifier. It's API offers a rich set of features:
- Configure text preparation task such as amplify negation, tokenize, stem, remove stop words, and propagate negation using wink-nlp-utils or any other package of your choice.
- Configure Lidstone or Lapalce additive smoothing.
- Configure Multinomial or Binarized Multinomial Naive Bayes model.
- Export and import learnings in JSON format that can be easily saved on hard-disk.
- Evaluate learning to perform n-fold cross validation.
- Obtain comprehensive metrics including confusion matrix, precision, and recall.
Use npm to install:
npm install wink-naive-bayes-text-classifier --save
// Load Naive Bayes Text Classifiervar Classifier = ;// Instantiatevar nbc = ;// Load NLP utilitiesvar nlp = ;// Configure preparation tasksnbc;// Configure behaviornbc;// Train!nbc;nbc;nbc;nbc;nbc;nbc;nbc;nbc;nbc;// Consolidate all the training!!nbc;// Start predicting...console;// -> autoloanconsole;// -> prepay
Try experimenting with this example on Runkit in the browser.
Check out the Naive Bayes Text Classifier API documentation to learn more.
If you spot a bug and the same has not yet been reported, raise a new issue or consider fixing it and sending a pull request.
Wink is a family of open source packages for Statistical Analysis, Natural Language Processing and Machine Learning in NodeJS. The code is thoroughly documented for easy human comprehension and has a test coverage of ~100% for reliability to build production grade solutions.
Copyright & License
wink-naive-bayes-text-classifier is copyright 2017-19 GRAYPE Systems Private Limited.
It is licensed under the terms of the MIT License.