LBJ2.learn
Class Learner

java.lang.Object
  extended by LBJ2.classify.Classifier
      extended by LBJ2.learn.Learner
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable
Direct Known Subclasses:
AdaBoost, LinearThresholdUnit, MuxLearner, NaiveBayes, SparseNetworkLearner, StochasticGradientDescent, WekaWrapper

public abstract class Learner
extends Classifier

Extend this class to create a new Classifier that learns to mimic one an oracle classifier given a feature extracting classifier and example objects.

See Also:
Serialized Form

Field Summary
protected  Classifier extractor
          Stores the classifiers used to produce features.
protected  Classifier labeler
          Stores the classifier used to produce labels.
 
Fields inherited from class LBJ2.classify.Classifier
containingPackage, name
 
Constructor Summary
protected Learner()
          This constructor is used by the LBJ2 compiler; it should never be called by a programmer.
protected Learner(java.lang.String n)
          Initializes the name.
protected Learner(java.lang.String n, Classifier e)
          Constructor for unsupervised learning.
protected Learner(java.lang.String n, Classifier l, Classifier e)
          Constructor for supervised learning.
 
Method Summary
 void doneLearning()
          Overridden by subclasses to perform any required post-processing computations after all training examples have been observed through learn(Object) and learn(Object[]).
abstract  void forget()
          Overridden by subclasses to reinitialize the learner to the state it started at before any learning was performed.
 Classifier getExtractor()
          Returns the extractor.
 Classifier getLabeler()
          Returns the labeler.
abstract  void learn(java.lang.Object example)
          Trains the learning algorithm given an object as an example.
 void learn(java.lang.Object[] examples)
          Trains the learning algorithm given many objects as examples.
 void save()
          Overridden by subclasses to store a binary representation of this learner in a pre-defined location.
abstract  ScoreSet scores(java.lang.Object example)
          Produces a set of scores indicating the degree to which each possible discrete classification value is associated with the given example object.
 void setExtractor(Classifier e)
          Sets the extractor.
 void setLabeler(Classifier l)
          Sets the labeler.
abstract  void write(java.io.PrintStream out)
          Writes the algorithm's internal representation as text.
 
Methods inherited from class LBJ2.classify.Classifier
allowableValues, binaryRead, binaryRead, binaryRead, binaryRead, binaryWrite, binaryWrite, classify, classify, clone, discreteValue, discreteValueArray, getCompositeChildren, getInputType, getOutputType, realValue, realValueArray, test, toString, valueIndexOf
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

labeler

protected Classifier labeler
Stores the classifier used to produce labels.


extractor

protected Classifier extractor
Stores the classifiers used to produce features.

Constructor Detail

Learner

protected Learner()
This constructor is used by the LBJ2 compiler; it should never be called by a programmer.


Learner

protected Learner(java.lang.String n)
Initializes the name.

Parameters:
n - The name of the classifier.

Learner

protected Learner(java.lang.String n,
                  Classifier e)
Constructor for unsupervised learning.

Parameters:
n - The name of the classifier.
e - The feature extracting classifier.

Learner

protected Learner(java.lang.String n,
                  Classifier l,
                  Classifier e)
Constructor for supervised learning.

Parameters:
n - The name of the classifier.
l - The labeling classifier.
e - The feature extracting classifier.
Method Detail

getLabeler

public Classifier getLabeler()
Returns the labeler.


setLabeler

public void setLabeler(Classifier l)
Sets the labeler.

Parameters:
l - A labeling classifier.

getExtractor

public Classifier getExtractor()
Returns the extractor.


setExtractor

public void setExtractor(Classifier e)
Sets the extractor.

Parameters:
e - A feature extracting classifier.

learn

public abstract void learn(java.lang.Object example)
Trains the learning algorithm given an object as an example.

Parameters:
example - An example of the desired learned classifier's behavior.

learn

public void learn(java.lang.Object[] examples)
Trains the learning algorithm given many objects as examples. This implementation simply calls learn(Object) on each of the objects in the input array. It should be overridden if there is a more efficient implementation.

Parameters:
examples - Examples of the desired learned classifier's behavior.

doneLearning

public void doneLearning()
Overridden by subclasses to perform any required post-processing computations after all training examples have been observed through learn(Object) and learn(Object[]). By default this method does nothing.


forget

public abstract void forget()
Overridden by subclasses to reinitialize the learner to the state it started at before any learning was performed.


save

public void save()
Overridden by subclasses to store a binary representation of this learner in a pre-defined location. By default this method does nothing.


scores

public abstract ScoreSet scores(java.lang.Object example)
Produces a set of scores indicating the degree to which each possible discrete classification value is associated with the given example object. Learners that return a real feature or more than one feature may implement this method by simply returning null.

Parameters:
example - The object to make decisions about.
Returns:
A set of scores indicating the degree to which each possible discrete classification value is associated with the given example object.

write

public abstract void write(java.io.PrintStream out)
Writes the algorithm's internal representation as text.

Parameters:
out - The output stream.