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