You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@mahout.apache.org by skasab2s <sk...@smail.inf.fh-brs.de> on 2011/05/03 17:15:00 UTC
Nave Bayes Classifier and probability calculation for a single test
example
Hello,
I tried out Mahout's Naive Bayes example for "history and science" and it
worked great! I have a question about the classifying part:
for (Map.Entry<String, List<String>> stringListEntry :
document.entrySet()) {
List<String> strings = stringListEntry.getValue();
ClassifierResult classifiedLabel = classifier.classify(model,
strings.toArray(new String[strings.size()]),
defaultCat);
...
boolean correct = resultAnalyzer.addInstance(correctLabel, classifiedLabel);
}
As a result for a single test example (in this case 'document'), we get a
boolean value. I'm a little bit confused, because as far as I know, Naive
Bayes is a probabilistic model
(http://en.wikipedia.org/wiki/Naive_Bayes_classifier) and when classifying a
single instance, it should return a probability (measured in percentage, and
not in true/false).
So, how can I get a percentage instead of a boolean when using Naive Bayes /
Complementary Bayes?
Many thanks and best regards!
Svetlomir Kasabov
--
View this message in context: http://lucene.472066.n3.nabble.com/Nave-Bayes-Classifier-and-probability-calculation-for-a-single-test-example-tp2894633p2894633.html
Sent from the Mahout User List mailing list archive at Nabble.com.
Re: Nave Bayes Classifier and probability calculation for a singletest edxample
Posted by ta...@gmail.com.
Sent from BlackBerry® on Airtel
-----Original Message-----
From: gaurav garg <ga...@gmail.com>
Date: Wed, 4 May 2011 00:37:53
To: <us...@mahout.apache.org>
Reply-To: user@mahout.apache.org
Cc: <ma...@lucene.apache.org>
Subject: Re: Nave Bayes Classifier and probability calculation for a single
test example
Hi Svetlomir,
You can use ClassifierContext class (
https://builds.apache.org/hudson/job/Mahout-Quality/javadoc/index.html?org/apache/mahout/common/StringTuple.html)
to get the top N matching result and their respective scores.
Hope it helps.
Thanks
Gaurav
Re: Nave Bayes Classifier and probability calculation for a single
test example
Posted by gaurav garg <ga...@gmail.com>.
Hi Svetlomir,
You can use ClassifierContext class (
https://builds.apache.org/hudson/job/Mahout-Quality/javadoc/index.html?org/apache/mahout/common/StringTuple.html)
to get the top N matching result and their respective scores.
Hope it helps.
Thanks
Gaurav