use of org.apache.lucene.classification.BooleanPerceptronClassifier in project lucene-solr by apache.
the class ConfusionMatrixGeneratorTest method testGetConfusionMatrixWithBP.
@Test
public void testGetConfusionMatrixWithBP() throws Exception {
LeafReader reader = null;
try {
MockAnalyzer analyzer = new MockAnalyzer(random());
reader = getSampleIndex(analyzer);
Classifier<Boolean> classifier = new BooleanPerceptronClassifier(reader, analyzer, null, 1, null, booleanFieldName, textFieldName);
ConfusionMatrixGenerator.ConfusionMatrix confusionMatrix = ConfusionMatrixGenerator.getConfusionMatrix(reader, classifier, booleanFieldName, textFieldName, -1);
checkCM(confusionMatrix);
assertTrue(confusionMatrix.getPrecision("true") >= 0d);
assertTrue(confusionMatrix.getPrecision("true") <= 1d);
assertTrue(confusionMatrix.getPrecision("false") >= 0d);
assertTrue(confusionMatrix.getPrecision("false") <= 1d);
assertTrue(confusionMatrix.getRecall("true") >= 0d);
assertTrue(confusionMatrix.getRecall("true") <= 1d);
assertTrue(confusionMatrix.getRecall("false") >= 0d);
assertTrue(confusionMatrix.getRecall("false") <= 1d);
assertTrue(confusionMatrix.getF1Measure("true") >= 0d);
assertTrue(confusionMatrix.getF1Measure("true") <= 1d);
assertTrue(confusionMatrix.getF1Measure("false") >= 0d);
assertTrue(confusionMatrix.getF1Measure("false") <= 1d);
} finally {
if (reader != null) {
reader.close();
}
}
}
Aggregations