edu.cmu.minorthird.classify.relational
Class StackedBatchClassifierLearner

java.lang.Object
  extended by edu.cmu.minorthird.classify.relational.StackedBatchClassifierLearner
All Implemented Interfaces:
ClassifierLearner, java.lang.Cloneable
Direct Known Subclasses:
StackedGraphicalLearner

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

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

Author:
Zhenzhen Kou

Field Summary
protected  Classifier classifier
           
protected  RealRelationalDataset dataset
          This variable saves the last classifier produced by batchTrain.
 
Constructor Summary
StackedBatchClassifierLearner()
           
 
Method Summary
 void addExample(Example answeredQuery)
          Accept a labeled example.
abstract  Classifier batchTrain(RealRelationalDataset RelDataset)
          subclasses should use this method to implement a batch supervised learning algorithm.
 void completeTraining()
          Accept a signal that no more training data is available.
 ClassifierLearner copy()
          Make a copy of the learner.
 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.
 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
 

Field Detail

dataset

protected RealRelationalDataset dataset
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.


classifier

protected Classifier classifier
Constructor Detail

StackedBatchClassifierLearner

public StackedBatchClassifierLearner()
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

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

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

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

batchTrain

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