Friday, November 21, 2014

ptnplanet/Java-Naive-Bayes-Classifier


ptnplanet/Java-Naive-Bayes-Classifier

Nothing special. It works and is well documented, so you should get it running without wasting too much time searching for other alternatives on the net.

Overview

I like talking about features and categories. Objects have features and may belong to a category. The classifier will try matching objects to their categories by looking at the objects' features. It does so by consulting its memory filled with knowledge gathered from training examples.

Classifying a feature-set results in the highest product of 1) the probability of that category to occur and 2) the product of all the features' probabilities to occure in that category:

classify(feature1, ..., featureN) = argmax(P(category) * PROD(P(feature|category)))

This is a so-called maximum a posteriori estimation. Wikipedia actually does a good job explaining it: http://en.wikipedia.org/wiki/Naive_Bayes_classifier#Probabilistic_model

Learning from Examples

Add knowledge by telling the classifier, that these features belong to a specific category:

String[] positiveText = "I love sunny days".split("\\s");  bayes.learn("positive", Arrays.asList(positiveText));

Read full article from ptnplanet/Java-Naive-Bayes-Classifier

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.