diff --git a/lucene/classification/src/test/org/apache/lucene/classification/BM25NBClassifierTest.java b/lucene/classification/src/test/org/apache/lucene/classification/BM25NBClassifierTest.java index 724f2a66e3c..237c53fd643 100644 --- a/lucene/classification/src/test/org/apache/lucene/classification/BM25NBClassifierTest.java +++ b/lucene/classification/src/test/org/apache/lucene/classification/BM25NBClassifierTest.java @@ -96,22 +96,15 @@ public class BM25NBClassifierTest extends ClassificationTestBase { MockAnalyzer analyzer = new MockAnalyzer(random()); LeafReader leafReader = getRandomIndex(analyzer, 100); try { - long trainStart = System.currentTimeMillis(); BM25NBClassifier classifier = new BM25NBClassifier(leafReader, analyzer, null, categoryFieldName, textFieldName); - long trainEnd = System.currentTimeMillis(); - long trainTime = trainEnd - trainStart; - assertTrue("training took more than 10s: " + trainTime / 1000 + "s", trainTime < 10000); - long evaluationStart = System.currentTimeMillis(); ConfusionMatrixGenerator.ConfusionMatrix confusionMatrix = ConfusionMatrixGenerator.getConfusionMatrix(leafReader, classifier, categoryFieldName, textFieldName, -1); assertNotNull(confusionMatrix); - long evaluationEnd = System.currentTimeMillis(); - long evaluationTime = evaluationEnd - evaluationStart; - assertTrue("evaluation took more than 2m: " + evaluationTime / 1000 + "s", evaluationTime < 120000); + double avgClassificationTime = confusionMatrix.getAvgClassificationTime(); - assertTrue("avg classification time: " + avgClassificationTime, 5000 > avgClassificationTime); + assertTrue(avgClassificationTime >= 0); double f1 = confusionMatrix.getF1Measure(); assertTrue(f1 >= 0d); diff --git a/lucene/classification/src/test/org/apache/lucene/classification/BooleanPerceptronClassifierTest.java b/lucene/classification/src/test/org/apache/lucene/classification/BooleanPerceptronClassifierTest.java index 5ecf9c67465..9f22e6fc5c0 100644 --- a/lucene/classification/src/test/org/apache/lucene/classification/BooleanPerceptronClassifierTest.java +++ b/lucene/classification/src/test/org/apache/lucene/classification/BooleanPerceptronClassifierTest.java @@ -86,21 +86,14 @@ public class BooleanPerceptronClassifierTest extends ClassificationTestBase avgClassificationTime); + assertTrue(avgClassificationTime >= 0); double f1 = confusionMatrix.getF1Measure(); assertTrue(f1 >= 0d); diff --git a/lucene/classification/src/test/org/apache/lucene/classification/CachingNaiveBayesClassifierTest.java b/lucene/classification/src/test/org/apache/lucene/classification/CachingNaiveBayesClassifierTest.java index ccdb207659a..00fa4fe3505 100644 --- a/lucene/classification/src/test/org/apache/lucene/classification/CachingNaiveBayesClassifierTest.java +++ b/lucene/classification/src/test/org/apache/lucene/classification/CachingNaiveBayesClassifierTest.java @@ -95,22 +95,15 @@ public class CachingNaiveBayesClassifierTest extends ClassificationTestBase avgClassificationTime); + assertTrue(avgClassificationTime >= 0); double accuracy = confusionMatrix.getAccuracy(); assertTrue(accuracy >= 0d); assertTrue(accuracy <= 1d); diff --git a/lucene/classification/src/test/org/apache/lucene/classification/KNearestFuzzyClassifierTest.java b/lucene/classification/src/test/org/apache/lucene/classification/KNearestFuzzyClassifierTest.java index 5c5122a1961..91cf943894e 100644 --- a/lucene/classification/src/test/org/apache/lucene/classification/KNearestFuzzyClassifierTest.java +++ b/lucene/classification/src/test/org/apache/lucene/classification/KNearestFuzzyClassifierTest.java @@ -69,21 +69,15 @@ public class KNearestFuzzyClassifierTest extends ClassificationTestBase classifier = new KNearestFuzzyClassifier(leafReader, null, analyzer, null, 3, categoryFieldName, textFieldName); - long trainEnd = System.currentTimeMillis(); - long trainTime = trainEnd - trainStart; - assertTrue("training took more than 10s: " + trainTime / 1000 + "s", trainTime < 10000); - long evaluationStart = System.currentTimeMillis(); ConfusionMatrixGenerator.ConfusionMatrix confusionMatrix = ConfusionMatrixGenerator.getConfusionMatrix(leafReader, classifier, categoryFieldName, textFieldName, -1); assertNotNull(confusionMatrix); - long evaluationEnd = System.currentTimeMillis(); - long evaluationTime = evaluationEnd - evaluationStart; - assertTrue("evaluation took more than 2m: " + evaluationTime / 1000 + "s", evaluationTime < 120000); + double avgClassificationTime = confusionMatrix.getAvgClassificationTime(); - assertTrue(5000 > avgClassificationTime); + assertTrue(avgClassificationTime >= 0); + double accuracy = confusionMatrix.getAccuracy(); assertTrue(accuracy >= 0d); assertTrue(accuracy <= 1d); diff --git a/lucene/classification/src/test/org/apache/lucene/classification/KNearestNeighborClassifierTest.java b/lucene/classification/src/test/org/apache/lucene/classification/KNearestNeighborClassifierTest.java index 5e3ce7bfff3..ab7318531e9 100644 --- a/lucene/classification/src/test/org/apache/lucene/classification/KNearestNeighborClassifierTest.java +++ b/lucene/classification/src/test/org/apache/lucene/classification/KNearestNeighborClassifierTest.java @@ -125,22 +125,16 @@ public class KNearestNeighborClassifierTest extends ClassificationTestBase avgClassificationTime); + assertTrue(avgClassificationTime >= 0); + double accuracy = confusionMatrix.getAccuracy(); assertTrue(accuracy >= 0d); assertTrue(accuracy <= 1d); 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 0e05d4fe8b9..be1eab1efa0 100644 --- a/lucene/classification/src/test/org/apache/lucene/classification/SimpleNaiveBayesClassifierTest.java +++ b/lucene/classification/src/test/org/apache/lucene/classification/SimpleNaiveBayesClassifierTest.java @@ -98,22 +98,15 @@ public class SimpleNaiveBayesClassifierTest extends ClassificationTestBase avgClassificationTime); + assertTrue(avgClassificationTime >= 0); double f1 = confusionMatrix.getF1Measure(); assertTrue(f1 >= 0d);