public class KNearestNeighborClassifier extends Object implements Classifier<BytesRef>
http://en.wikipedia.org/wiki/K-nearest_neighbors) based
on MoreLikeThis| Constructor and Description |
|---|
KNearestNeighborClassifier(int k)
Create a
Classifier using kNN algorithm |
| Modifier and Type | Method and Description |
|---|---|
ClassificationResult<BytesRef> |
assignClass(String text)
Assign a class (with score) to the given text String
|
void |
train(AtomicReader atomicReader,
String textFieldName,
String classFieldName,
Analyzer analyzer)
Train the classifier using the underlying Lucene index
|
public KNearestNeighborClassifier(int k)
Classifier using kNN algorithmk - the number of neighbors to analyze as an intpublic ClassificationResult<BytesRef> assignClass(String text) throws IOException
assignClass in interface Classifier<BytesRef>text - a String containing text to be classifiedClassificationResult holding assigned class of type T and scoreIOException - If there is a low-level I/O error.public void train(AtomicReader atomicReader, String textFieldName, String classFieldName, Analyzer analyzer) throws IOException
train in interface Classifier<BytesRef>atomicReader - the reader to use to access the Lucene indextextFieldName - the name of the field used to compare documentsclassFieldName - the name of the field containing the class assigned to documentsanalyzer - the analyzer used to tokenize / filter the unseen textIOException - If there is a low-level I/O error.Copyright © 2000-2013 Apache Software Foundation. All Rights Reserved.