![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
naivebayesclassifier
Advanced tools
NaiveBayesClassifier is a Multinomial Naive-Bayes Classifier that uses Laplace Smoothing.
NaiveBayesClassifier is an implementation of a Multinomial Naive-Bayes Classifier that uses Laplace Smoothing. It takes in a piece of text and tells you which category it most likely belongs to.
"In machine learning, naive Bayes classifiers are a family of simple probabilistic classifiers based on applying Bayes' theorem with strong (naive) independence assumptions between the features." - Wikipedia: Naive Bayes classifier.
You can use this implementation for categorizing any text content into any arbitrary set of categories. For example:
Depending on your specific attributes and sample size, there may be other algorithms that are better suited: Comparison of Classification Methods Based on the Type of Attributes and Sample Size.
You can experiment, test and play with NaiveBayesClassifier
in your browser at http://jsbin.com/xixuga/1/edit?html,js,console
If you would like to try NaiveBayesClassifier
as a web-service, you can use: http://nbcaas.herokuapp.com/
NaiveBayesClassifier
NaiveBayesClassifier
is shipped in UMD format, meaning that it is available as a CommonJS/AMD module or browser global. You can install it using npm
:
$ npm install naivebayesclassifier
OR using bower
:
$ bower install naivebayesclassifier
new NaiveBayesClassifier([options])
Using the default tokenization function, which splits on spaces:
var NaiveBayesClassifier = require('NaiveBayesClassifier'),
classifier = new NaiveBayesClassifier();
Or with an optional custom tokenization function that you specify:
var NaiveBayesClassifier = require('NaiveBayesClassifier');
var splitOnChar = function(text) {
return text.split('');
};
var classifier = new NaiveBayesClassifier({ tokenizer: splitOnChar });
.withClassifier(classifier)
Recover an existing classifier
, which you may have retrieved from a database or localstorage:
var NaiveBayesClassifier = require('NaiveBayesClassifier'),
classifier = NaiveBayesClassifier.withClassifier(existingClassifier);
.learn(text, category)
Teach your classifier what category
the text
belongs to. The more you teach your classifier, the more reliable it becomes. It will use what it has learned to identify new documents that it hasn't seen before.
classifier.learn('amazing, awesome movie!! Yeah!!', 'positive');
classifier.learn('terrible, shitty thing. Damn. Sucks!!', 'negative');
classifier.learn('I dont really know what to make of this.', 'neutral');
.categorize(text)
classifier.categorize('awesome, cool, amazing!! Yay.');
This will return the most likely category
it thinks text
belongs to and its probability
. Its judgement is based on what you have taught it with .learn(text, category)
.
{
"category": "positive",
"probability": 0.7687012152002337,
"categories":
{
"positive": 0.7687012152002337,
"negative": 0.15669449587155299,
"neutral": 0.07460428892821332
}
}
If you would like to explore the full API, you can find auto-generated documentation at: https://hadi.io/NaiveBayesClassifier.
This implementation is based on the Stanford NLP video series by Professor Dan Jurafsky & Chris Manning. This library modifies and extends work first investigated by Tolga Tezel.
Copyright (C) 2015, Hadi Michael. All rights reserved.
Licensed under BSD-3-Clause
FAQs
NaiveBayesClassifier is a Multinomial Naive-Bayes Classifier that uses Laplace Smoothing.
We found that naivebayesclassifier demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.