edu.cmu.minorthird.classify
Class OneVsAllLearner

java.lang.Object
  extended by edu.cmu.minorthird.classify.OneVsAllLearner
All Implemented Interfaces:
ClassifierLearner, java.lang.Cloneable
Direct Known Subclasses:
CascadingBinaryLearner, ManyVsRestLearner, MostFrequentFirstLearner, Recommended.OneVsAllLearner

public class OneVsAllLearner
extends java.lang.Object
implements ClassifierLearner

Multi-class version of a binary classifier.

Author:
William Cohen

Nested Class Summary
static class OneVsAllLearner.IllegalArgumentException
           
 
Field Summary
protected  java.util.List<ClassifierLearner> innerLearner
           
protected  ClassifierLearner learner
           
protected  ClassifierLearnerFactory learnerFactory
           
protected  java.lang.String learnerName
           
protected  ExampleSchema schema
           
 
Constructor Summary
OneVsAllLearner()
           
OneVsAllLearner(ClassifierLearner learner)
           
OneVsAllLearner(ClassifierLearnerFactory learnerFactory)
          Deprecated. use OneVsAllLearner(BatchClassifierLearner learner)
OneVsAllLearner(java.lang.String learnerName)
           
 
Method Summary
 void addExample(Example answeredQuery)
          Accept a labeled example.
 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.
 ClassifierLearner getInnerLearner()
           
 ExampleSchema getSchema()
          Returns the ExampleSchema - constraints on what the Examples will be.
 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 setInnerLearner(ClassifierLearner learner)
           
 void setInstancePool(java.util.Iterator<Instance> iterator)
          Accept a set of unlabeled instances.
 void setSchema(ExampleSchema schema)
          Accept an ExampleSchema - constraints on what the Examples will be.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

learnerFactory

protected ClassifierLearnerFactory learnerFactory

learner

protected ClassifierLearner learner

learnerName

protected java.lang.String learnerName

innerLearner

protected java.util.List<ClassifierLearner> innerLearner

schema

protected ExampleSchema schema
Constructor Detail

OneVsAllLearner

public OneVsAllLearner()

OneVsAllLearner

public OneVsAllLearner(ClassifierLearnerFactory learnerFactory)
Deprecated. use OneVsAllLearner(BatchClassifierLearner learner)

Parameters:
learnerFactory - a ClassifierLearnerFactory which should produce a BinaryClassifier with each call.

OneVsAllLearner

public OneVsAllLearner(java.lang.String learnerName)

OneVsAllLearner

public OneVsAllLearner(ClassifierLearner learner)
Method Detail

setInnerLearner

public void setInnerLearner(ClassifierLearner learner)

getInnerLearner

public ClassifierLearner getInnerLearner()

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

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

reset

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

Specified by:
reset in interface ClassifierLearner

setInstancePool

public void setInstancePool(java.util.Iterator<Instance> iterator)
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 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 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 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 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 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