Fork me on GitHub
  • API

    Show / Hide Table of Contents

    Class KNearestNeighborClassifier

    A k-Nearest Neighbor classifier (see http://en.wikipedia.org/wiki/K-nearest_neighbors) based on Lucene.Net.Queries.Mlt.MoreLikeThis

    Note

    This API is experimental and might change in incompatible ways in the next release.

    Inheritance
    object
    KNearestNeighborClassifier
    Implements
    IClassifier<BytesRef>
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Lucene.Net.Classification
    Assembly: Lucene.Net.Classification.dll
    Syntax
    public class KNearestNeighborClassifier : IClassifier<BytesRef>

    Constructors

    KNearestNeighborClassifier(int)

    Create a IClassifier<T> using kNN algorithm

    Declaration
    public KNearestNeighborClassifier(int k)
    Parameters
    Type Name Description
    int k

    the number of neighbors to analyze as an int

    KNearestNeighborClassifier(int, int, int)

    Create a IClassifier<T> using kNN algorithm

    Declaration
    public KNearestNeighborClassifier(int k, int minDocsFreq, int minTermFreq)
    Parameters
    Type Name Description
    int k

    the number of neighbors to analyze as an int

    int minDocsFreq

    the minimum number of docs frequency for MLT to be set with Lucene.Net.Queries.Mlt.MoreLikeThis.MinDocFreq

    int minTermFreq

    the minimum number of term frequency for MLT to be set with Lucene.Net.Queries.Mlt.MoreLikeThis.MinTermFreq

    Methods

    AssignClass(string)

    Assign a class (with score) to the given text string

    Declaration
    public virtual ClassificationResult<BytesRef> AssignClass(string text)
    Parameters
    Type Name Description
    string text

    a string containing text to be classified

    Returns
    Type Description
    ClassificationResult<BytesRef>

    a ClassificationResult<T> holding assigned class of type Lucene.Net.Util.BytesRef and score

    Train(AtomicReader, string, string, Analyzer)

    Train the classifier using the underlying Lucene index

    Declaration
    public virtual void Train(AtomicReader atomicReader, string textFieldName, string classFieldName, Analyzer analyzer)
    Parameters
    Type Name Description
    AtomicReader atomicReader

    the reader to use to access the Lucene index

    string textFieldName

    the name of the field used to compare documents

    string classFieldName

    the name of the field containing the class assigned to documents

    Analyzer analyzer

    the analyzer used to tokenize / filter the unseen text

    Train(AtomicReader, string, string, Analyzer, Query)

    Train the classifier using the underlying Lucene index

    Declaration
    public virtual void Train(AtomicReader atomicReader, string textFieldName, string classFieldName, Analyzer analyzer, Query query)
    Parameters
    Type Name Description
    AtomicReader atomicReader

    the reader to use to access the Lucene index

    string textFieldName

    the name of the field used to compare documents

    string classFieldName

    the name of the field containing the class assigned to documents

    Analyzer analyzer

    the analyzer used to tokenize / filter the unseen text

    Query query

    the query to filter which documents use for training

    Train(AtomicReader, string[], string, Analyzer, Query)

    Train the classifier using the underlying Lucene index

    Declaration
    public virtual void Train(AtomicReader atomicReader, string[] textFieldNames, string classFieldName, Analyzer analyzer, Query query)
    Parameters
    Type Name Description
    AtomicReader atomicReader

    the reader to use to access the Lucene index

    string[] textFieldNames

    the names of the fields to be used to compare documents

    string classFieldName

    the name of the field containing the class assigned to documents

    Analyzer analyzer

    the analyzer used to tokenize / filter the unseen text

    Query query

    the query to filter which documents use for training

    Implements

    IClassifier<T>
    Back to top Copyright © 2024 The Apache Software Foundation, Licensed under the Apache License, Version 2.0
    Apache Lucene.Net, Lucene.Net, Apache, the Apache feather logo, and the Apache Lucene.Net project logo are trademarks of The Apache Software Foundation.
    All other marks mentioned may be trademarks or registered trademarks of their respective owners.