LUCENE-6854 - adjusted precision calculation, minor fix in SNBC test

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1723759 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Tommaso Teofili 2016-01-08 16:49:48 +00:00
parent 2580956b8b
commit 056940632d
2 changed files with 4 additions and 3 deletions

View File

@ -167,7 +167,7 @@ public class ConfusionMatrixGenerator {
public double getPrecision(String klass) {
Map<String, Long> classifications = linearizedMatrix.get(klass);
double tp = 0;
double fp = 0;
double fp = -1;
if (classifications != null) {
for (Map.Entry<String, Long> entry : classifications.entrySet()) {
if (klass.equals(entry.getKey())) {
@ -253,7 +253,7 @@ public class ConfusionMatrixGenerator {
*/
public double getPrecision() {
double tp = 0;
double fp = 0;
double fp = -linearizedMatrix.size();
for (Map.Entry<String, Map<String, Long>> classification : linearizedMatrix.entrySet()) {
String klass = classification.getKey();
for (Map.Entry<String, Long> entry : classification.getValue().entrySet()) {

View File

@ -75,7 +75,8 @@ public class SimpleNaiveBayesClassifierTest extends ClassificationTestBase<Bytes
try {
Analyzer analyzer = new NGramAnalyzer();
leafReader = getSampleIndex(analyzer);
checkCorrectClassification(new CachingNaiveBayesClassifier(leafReader, analyzer, null, categoryFieldName, textFieldName), TECHNOLOGY_INPUT, TECHNOLOGY_RESULT);
SimpleNaiveBayesClassifier classifier = new SimpleNaiveBayesClassifier(leafReader, analyzer, null, categoryFieldName, textFieldName);
checkCorrectClassification(classifier, TECHNOLOGY_INPUT, TECHNOLOGY_RESULT);
} finally {
if (leafReader != null) {
leafReader.close();