edu.cmu.minorthird.classify
Class OnlineClassifierLearner

java.lang.Object
  extended by edu.cmu.minorthird.classify.OnlineClassifierLearner
All Implemented Interfaces:
ClassifierLearner, java.lang.Cloneable
Direct Known Subclasses:
KnnLearner, MistakeCountingOnlineLearner, OnlineBinaryClassifierLearner, OnlineVersion

public abstract class OnlineClassifierLearner
extends java.lang.Object
implements ClassifierLearner

Abstract ClassifierLearner which instantiates the teacher-learner protocol so as to implement a standard on-line learner.

Author:
William Cohen

Constructor Summary
OnlineClassifierLearner()
           
 
Method Summary
abstract  void addExample(Example answeredQuery)
          Subclasses should use this method to perform whatever incremental update is needed after in response to a new example.
 void completeTraining()
          A promise from the caller that no further examples will be added.
 ClassifierLearner copy()
          Make a copy of the learner.
abstract  Classifier getClassifier()
          Subclasses should use this method to return the current classifier.
 boolean hasNextQuery()
          Returns true if the learner has more queries to answer.
 Instance nextQuery()
          Returns an Instance for which the learner would like a label.
abstract  void reset()
          'forget' everything about the last learning task, and start a new task.
 void setInstancePool(java.util.Iterator<Instance> i)
          Accept a set of unlabeled instances.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface edu.cmu.minorthird.classify.ClassifierLearner
getSchema, setSchema
 

Constructor Detail

OnlineClassifierLearner

public OnlineClassifierLearner()
Method Detail

setInstancePool

public final void setInstancePool(java.util.Iterator<Instance> i)
Description copied from interface: ClassifierLearner
Accept a set of unlabeled instances. These might be used in formulating queries in active learning, or for semi-supervised learning. Queries are made with the methods hasNextQuery(), nextQuery(), and setAnswer().

Learners need not make use of the instance pool.

Specified by:
setInstancePool in interface ClassifierLearner

hasNextQuery

public final boolean hasNextQuery()
Description copied from interface: ClassifierLearner
Returns true if the learner has more queries to answer.

Learners may always return 'false', if they are not active.

Specified by:
hasNextQuery in interface ClassifierLearner

nextQuery

public final Instance nextQuery()
Description copied from interface: ClassifierLearner
Returns an Instance for which the learner would like a label.

This will only be called if hasNextQuery() returns true.

Specified by:
nextQuery in interface ClassifierLearner

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

completeTraining

public void completeTraining()
A promise from the caller that no further examples will be added. Override this method if it's appropriate.

Specified by:
completeTraining in interface ClassifierLearner

addExample

public abstract void addExample(Example answeredQuery)
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

getClassifier

public abstract Classifier getClassifier()
Subclasses should use this method to return the current classifier.

Specified by:
getClassifier in interface ClassifierLearner

reset

public abstract void reset()
'forget' everything about the last learning task, and start a new task. Subclasses need to implement this method

Specified by:
reset in interface ClassifierLearner