|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.lucene.classification.KNearestNeighborClassifier
public class KNearestNeighborClassifier
A k-Nearest Neighbor classifier (see http://en.wikipedia.org/wiki/K-nearest_neighbors
) based
on MoreLikeThis
Constructor Summary | |
---|---|
KNearestNeighborClassifier(int k)
Create a Classifier using kNN algorithm |
Method Summary | |
---|---|
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 |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public KNearestNeighborClassifier(int k)
Classifier
using kNN algorithm
k
- the number of neighbors to analyze as an int
Method Detail |
---|
public ClassificationResult<BytesRef> assignClass(String text) throws IOException
assignClass
in interface Classifier<BytesRef>
text
- a String containing text to be classified
ClassificationResult
holding assigned class of type T
and score
IOException
- 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 text
IOException
- If there is a low-level I/O error.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |