Search in sources :

Example 1 with CachingNaiveBayesClassifier

use of org.apache.lucene.classification.CachingNaiveBayesClassifier in project lucene-solr by apache.

the class ConfusionMatrixGeneratorTest method testGetConfusionMatrixWithCNB.

@Test
public void testGetConfusionMatrixWithCNB() throws Exception {
    LeafReader reader = null;
    try {
        MockAnalyzer analyzer = new MockAnalyzer(random());
        reader = getSampleIndex(analyzer);
        Classifier<BytesRef> classifier = new CachingNaiveBayesClassifier(reader, analyzer, null, categoryFieldName, textFieldName);
        ConfusionMatrixGenerator.ConfusionMatrix confusionMatrix = ConfusionMatrixGenerator.getConfusionMatrix(reader, classifier, categoryFieldName, textFieldName, -1);
        checkCM(confusionMatrix);
    } finally {
        if (reader != null) {
            reader.close();
        }
    }
}
Also used : LeafReader(org.apache.lucene.index.LeafReader) MockAnalyzer(org.apache.lucene.analysis.MockAnalyzer) CachingNaiveBayesClassifier(org.apache.lucene.classification.CachingNaiveBayesClassifier) BytesRef(org.apache.lucene.util.BytesRef) Test(org.junit.Test)

Aggregations

MockAnalyzer (org.apache.lucene.analysis.MockAnalyzer)1 CachingNaiveBayesClassifier (org.apache.lucene.classification.CachingNaiveBayesClassifier)1 LeafReader (org.apache.lucene.index.LeafReader)1 BytesRef (org.apache.lucene.util.BytesRef)1 Test (org.junit.Test)1