Socket
Socket
Sign inDemoInstall

wink-naive-bayes-text-classifier

Package Overview
Dependencies
Maintainers
3
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wink-naive-bayes-text-classifier

Configurable Naive Bayes Classifier for text with cross-validation support


Version published
Maintainers
3
Created
Source

wink-naive-bayes-text-classifier

Configurable Naive Bayes Classifier for text with cross-validation support

Build Status Coverage Status Inline docs dependencies Status devDependencies Status Gitter

Classify text, analyse sentiments, recognize user intents for chatbot using wink-naive-bayes-text-classifier. It's API offers a rich set of features:

  1. 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.
  2. Configure Lidstone or Lapalce additive smoothing.
  3. Configure Multinomial or Binarized Multinomial Naive Bayes model.
  4. Export and import learnings in JSON format that can be easily saved on hard-disk.
  5. Evaluate learning to perform n-fold cross validation.
  6. Obtain comprehensive metrics including confusion matrix, precision, and recall.

Installation

Use npm to install:

npm install wink-naive-bayes-text-classifier --save

Example


// Load Naive Bayes Text Classifier
var Classifier = require( 'wink-naive-bayes-text-classifier' );
// Instantiate
var nbc = Classifier();
// Load NLP utilities
var nlp = require( 'wink-nlp-utils' );
// Configure preparation tasks
nbc.definePrepTasks( [
  // Simple tokenizer
  nlp.string.tokenize0,
  // Common Stop Words Remover
  nlp.tokens.removeWords,
  // Stemmer to obtain base word
  nlp.tokens.stem
] );
// Configure behavior
nbc.defineConfig( { considerOnlyPresence: true, smoothingFactor: 0.5 } );
// Train!
nbc.learn( 'I want to prepay my loan', 'prepay' );
nbc.learn( 'I want to close my loan', 'prepay' );
nbc.learn( 'I want to foreclose my loan', 'prepay' );
nbc.learn( 'I would like to pay the loan balance', 'prepay' );

nbc.learn( 'I would like to borrow money to buy a vehicle', 'autoloan' );
nbc.learn( 'I need loan for car', 'autoloan' );
nbc.learn( 'I need loan for a new vehicle', 'autoloan' );
nbc.learn( 'I need loan for a new mobike', 'autoloan' );
nbc.learn( 'I need money for a new car', 'autoloan' );
// Consolidate all the training!!
nbc.consolidate();
// Start predicting...
console.log( nbc.predict( 'I would like to borrow 50000 to buy a new Audi R8 in New York' ) );
// -> autoloan
console.log( nbc.predict( 'I want to pay my car loan early' ) );
// -> prepay

Try experimenting with this example on Runkit in the browser.

Documentation

Check out the Naive Bayes Text Classifier API documentation to learn more.

Need Help?

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.

About wink

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.

wink-naive-bayes-text-classifier is copyright 2017-18 GRAYPE Systems Private Limited.

It is licensed under the terms of the MIT License.

Keywords

FAQs

Package last updated on 05 Nov 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc