edu.cmu.minorthird.classify.algorithms.knn
Class KnnLearner

java.lang.Object
  extended by edu.cmu.minorthird.classify.OnlineClassifierLearner
      extended by edu.cmu.minorthird.classify.algorithms.knn.KnnLearner
All Implemented Interfaces:
ClassifierLearner, java.io.Serializable, java.lang.Cloneable

public class KnnLearner
extends OnlineClassifierLearner
implements java.io.Serializable

Learn an Knn Classifier.

Author:
William Cohen
See Also:
Serialized Form

Constructor Summary
KnnLearner()
           
KnnLearner(int k)
           
 
Method Summary
 void addExample(Example e)
          Subclasses should use this method to perform whatever incremental update is needed after in response to a new example.
 ClassifierLearner copy()
          Make a copy of the learner.
 Classifier getClassifier()
          Subclasses should use this method to return the current classifier.
 int getK()
           
 ExampleSchema getSchema()
          Returns the ExampleSchema - constraints on what the Examples will be.
 void reset()
          'forget' everything about the last learning task, and start a new task.
 void setK(int k)
           
 void setSchema(ExampleSchema schema)
          Accept an ExampleSchema - constraints on what the Examples will be.
 java.lang.String toString()
           
 
Methods inherited from class edu.cmu.minorthird.classify.OnlineClassifierLearner
completeTraining, hasNextQuery, nextQuery, setInstancePool
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

KnnLearner

public KnnLearner()

KnnLearner

public KnnLearner(int k)
Method Detail

copy

public ClassifierLearner copy()
Description copied from interface: ClassifierLearner
Make a copy of the learner. Note: This will reset the learner, erasing previous data!

Specified by:
copy in interface ClassifierLearner
Overrides:
copy in class OnlineClassifierLearner

getK

public int getK()

setK

public void setK(int k)

reset

public void reset()
Description copied from class: OnlineClassifierLearner
'forget' everything about the last learning task, and start a new task. Subclasses need to implement this method

Specified by:
reset in interface ClassifierLearner
Specified by:
reset in class OnlineClassifierLearner

addExample

public void addExample(Example e)
Description copied from class: OnlineClassifierLearner
Subclasses should use this method to perform whatever incremental update is needed after in response to a new example.

Specified by:
addExample in interface ClassifierLearner
Specified by:
addExample in class OnlineClassifierLearner

getClassifier

public Classifier getClassifier()
Description copied from class: OnlineClassifierLearner
Subclasses should use this method to return the current classifier.

Specified by:
getClassifier in interface ClassifierLearner
Specified by:
getClassifier in class OnlineClassifierLearner

setSchema

public void setSchema(ExampleSchema schema)
Description copied from interface: ClassifierLearner
Accept an ExampleSchema - constraints on what the Examples will be.

Specified by:
setSchema in interface ClassifierLearner

getSchema

public ExampleSchema getSchema()
Description copied from interface: ClassifierLearner
Returns the ExampleSchema - constraints on what the Examples will be.

Specified by:
getSchema in interface ClassifierLearner

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object