From 056940632d9ff19f2f581f8511bf3cf5de5208be Mon Sep 17 00:00:00 2001 From: Tommaso Teofili Date: Fri, 8 Jan 2016 16:49:48 +0000 Subject: [PATCH] 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 --- .../lucene/classification/utils/ConfusionMatrixGenerator.java | 4 ++-- .../lucene/classification/SimpleNaiveBayesClassifierTest.java | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lucene/classification/src/java/org/apache/lucene/classification/utils/ConfusionMatrixGenerator.java b/lucene/classification/src/java/org/apache/lucene/classification/utils/ConfusionMatrixGenerator.java index 2d7f912aec0..58d22c70eab 100644 --- a/lucene/classification/src/java/org/apache/lucene/classification/utils/ConfusionMatrixGenerator.java +++ b/lucene/classification/src/java/org/apache/lucene/classification/utils/ConfusionMatrixGenerator.java @@ -167,7 +167,7 @@ public class ConfusionMatrixGenerator { public double getPrecision(String klass) { Map classifications = linearizedMatrix.get(klass); double tp = 0; - double fp = 0; + double fp = -1; if (classifications != null) { for (Map.Entry 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> classification : linearizedMatrix.entrySet()) { String klass = classification.getKey(); for (Map.Entry entry : classification.getValue().entrySet()) { diff --git a/lucene/classification/src/test/org/apache/lucene/classification/SimpleNaiveBayesClassifierTest.java b/lucene/classification/src/test/org/apache/lucene/classification/SimpleNaiveBayesClassifierTest.java index ba7eed62e29..aa7de0cad62 100644 --- a/lucene/classification/src/test/org/apache/lucene/classification/SimpleNaiveBayesClassifierTest.java +++ b/lucene/classification/src/test/org/apache/lucene/classification/SimpleNaiveBayesClassifierTest.java @@ -75,7 +75,8 @@ public class SimpleNaiveBayesClassifierTest extends ClassificationTestBase