edu.cmu.minorthird.classify.semisupervised
Class SemiSupervisedBatchClassifierLearner

java.lang.Object
  extended by edu.cmu.minorthird.classify.semisupervised.SemiSupervisedBatchClassifierLearner
All Implemented Interfaces:
ClassifierLearner, java.lang.Cloneable
Direct Known Subclasses:
SemiSupervisedNaiveBayesLearner

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

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

Author:
Edoardo Airoldi

Field Summary
protected  Classifier classifier
          This variable saves the last classifier produced by batchTrain.
 
Constructor Summary
SemiSupervisedBatchClassifierLearner()
           
 
Method Summary
 void addExample(Example answeredQuery)
          Accept a labeled example.
abstract  Classifier batchTrain(SemiSupervisedDataset dataset)
          subclasses should use this method to implement a batch supervised learning algorithm.
 void completeTraining()
          Accept a signal that no more training data is available.
 Classifier getClassifier()
          Return the learned 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.
 void reset()
          Forget everything and prepare for a new learning session.
abstract  void setInstancePool(java.util.Iterator<Instance> i)
          subclasses should use this method to get the unlabeled examples available for semi-supervised learning.
abstract  void setSchema(ExampleSchema schema)
          Enables control on number of classes allowed to be passed to the learner
 
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
copy, getSchema
 

Field Detail

classifier

protected Classifier classifier
This variable saves the last classifier produced by batchTrain. If it is non-null, then it will be returned by class to getClassifier(). Implementations of batchTrain should save the returned classifier to avoid extra work.

Constructor Detail

SemiSupervisedBatchClassifierLearner

public SemiSupervisedBatchClassifierLearner()
Method Detail

reset

public final void reset()
Description copied from interface: ClassifierLearner
Forget everything and prepare for a new learning session.

Specified by:
reset 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

addExample

public final void addExample(Example answeredQuery)
Description copied from interface: ClassifierLearner
Accept a labeled example. The example might be the answer to the last query, or it may be an example chosen by the teacher.

All learners must provide a non-trivial implementation of addExample.

Specified by:
addExample in interface ClassifierLearner

completeTraining

public final void completeTraining()
Description copied from interface: ClassifierLearner
Accept a signal that no more training data is available. This would trigger any additional computation that might be useful to speed up or improve the results of getClassifier().

Specified by:
completeTraining in interface ClassifierLearner

getClassifier

public final Classifier getClassifier()
Description copied from interface: ClassifierLearner
Return the learned classifier. The classifier should take advantage of all information sent by the teacher to date. Teachers can assume that multiple calls to getClassifier() without intervening calls to addExample() will return the same object, and do little computation. Teachers can not assume that this object is immutable: for instance, in the case of an on-line learning method, the classifier that is returned might change after more examples are learned.

All learners must implement this method.

Specified by:
getClassifier in interface ClassifierLearner

setSchema

public abstract void setSchema(ExampleSchema schema)
Enables control on number of classes allowed to be passed to the learner

Specified by:
setSchema in interface ClassifierLearner

setInstancePool

public abstract void setInstancePool(java.util.Iterator<Instance> i)
subclasses should use this method to get the unlabeled examples available for semi-supervised learning.

Specified by:
setInstancePool in interface ClassifierLearner

batchTrain

public abstract Classifier batchTrain(SemiSupervisedDataset dataset)
subclasses should use this method to implement a batch supervised learning algorithm.