ir.classifiers
Class KNN

java.lang.Object
  |
  +--ir.classifiers.Classifier
        |
        +--ir.classifiers.KNN

public class KNN
extends Classifier


Field Summary
 boolean debug
           
protected  int K
           
 java.lang.String name
           
protected  ir.vsr.InvertedIndex trainDocs
           
 
Method Summary
 java.lang.String getName()
          Returns the name
 void setInvertedIndex(ir.vsr.InvertedIndex index)
          For classifiers that use invertedIndices, this function sets them -- needed for efficient memory management
 boolean test(Example testExample)
          Returns true if the predicted category of the test example matches the correct category, false otherwise
 void train(java.util.Vector train)
          Trains the classifier on the training examples
 boolean usesInvertedIndex()
          Function to indicate that this class uses an inverted index
 
Methods inherited from class ir.classifiers.Classifier
argMax
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

trainDocs

protected ir.vsr.InvertedIndex trainDocs

K

protected int K

debug

public boolean debug

name

public final java.lang.String name
Method Detail

usesInvertedIndex

public boolean usesInvertedIndex()
Function to indicate that this class uses an inverted index
Overrides:
usesInvertedIndex in class Classifier

setInvertedIndex

public void setInvertedIndex(ir.vsr.InvertedIndex index)
Description copied from class: Classifier
For classifiers that use invertedIndices, this function sets them -- needed for efficient memory management
Overrides:
setInvertedIndex in class Classifier

getName

public java.lang.String getName()
Returns the name
Overrides:
getName in class Classifier

train

public void train(java.util.Vector train)
Description copied from class: Classifier
Trains the classifier on the training examples
Overrides:
train in class Classifier

test

public boolean test(Example testExample)
Description copied from class: Classifier
Returns true if the predicted category of the test example matches the correct category, false otherwise
Overrides:
test in class Classifier