LBJ2.learn
Class MuxLearner

java.lang.Object
  extended by LBJ2.classify.Classifier
      extended by LBJ2.learn.Learner
          extended by LBJ2.learn.MuxLearner
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable

public class MuxLearner
extends Learner

A MuxLearner uses one of many Learners indexed by the first feature in an example to produce a classification. During training, the features produced by the first child classifier of this classifier's composite generator feature extractor are taken to determine which Learners will learn from the training object. For any given example, there must be one Feature produced by the labeler for each Feature produced by the first child classifier. If this classifier's feature extractor is not a composite generator, the first feature it produces is the only one taken.

It is assumed that the Learner being multiplexed expects a single label feature on each training example, and that the feature(s) used to do the multiplexing are DiscreteFeature(s). Furthermore, if this classifier's feature extractor is a composite generator, it must produce the same number of features as this classifier's labeler, and they must correspond to each other in the order produced.

This algorithm's user-configurable parameters are stored in member fields of this class. They may be set via either a constructor that names each parameter explicitly or a constructor that takes an instance of Parameters as input. The documentation in each member field in this class indicates the default value of the associated parameter when using the former type of constructor. The documentation of the associated member field in the Parameters class indicates the default value of the parameter when using the latter type of constructor.

See Also:
Serialized Form

Nested Class Summary
static class MuxLearner.Parameters
          Simply a container for all of MuxLearner's configurable parameters.
 
Field Summary
protected  Learner baseLearner
          Instances of this learning algorithm will be multiplexed; default null.
protected  java.util.LinkedList compositeChildren
          If this classifier's feature extractor is a composite generator, this list will contain every child classifier of that composite generator except the first; otherwise, it is null.
static java.lang.String defaultDefaultPrediction
          Default for defaultPrediction.
protected  java.lang.String defaultPrediction
          This string is returned during testing when the multiplexed Learner doesn't exist; default defaultDefaultPrediction.
protected  java.util.HashMap network
          A map from feature values to learners.
protected  Classifier select
          If this classifier's feature extractor is a composite generator, this member variable will reference the first child classifier of that composite generator; otherwise, it is null.
 
Fields inherited from class LBJ2.learn.Learner
extractor, labeler
 
Fields inherited from class LBJ2.classify.Classifier
containingPackage, name
 
Constructor Summary
MuxLearner()
          For the LBJ compiler; not for use by the LBJ user.
MuxLearner(Learner base)
          Instantiates this multiplexed learner using the specified base learning algorithm.
MuxLearner(Learner base, java.lang.String d)
          Instantiates this multiplexed learner using the specified base learning algorithm.
MuxLearner(MuxLearner.Parameters p)
          Initializing constructor.
MuxLearner(java.lang.String n)
          For the LBJ compiler; not for use by the LBJ user.
MuxLearner(java.lang.String n, Learner base)
          Instantiates this multiplexed learner using the specified base learning algorithm.
MuxLearner(java.lang.String n, Learner base, java.lang.String d)
          Instantiates this multiplexed learner using the specified base learning algorithm.
MuxLearner(java.lang.String n, MuxLearner.Parameters p)
          Initializing constructor.
 
Method Summary
 FeatureVector classify(java.lang.Object example)
          This method performs the multiplexing and returns the output of the selected Learner.
 java.lang.Object clone()
          Returns a deep clone of this learning algorithm.
 void forget()
          Clears the network.
 void learn(java.lang.Object example)
          The training example is multiplexed to the appropriate Learner(s).
 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 setBase(Learner base)
          Sets baseLearner.
 void setExtractor(Classifier e)
          Sets the extractor.
 void setLabeler(Classifier l)
          Sets the labeler.
 void write(java.io.PrintStream out)
          Writes the algorithm's internal representation as text.
 
Methods inherited from class LBJ2.learn.Learner
doneLearning, getExtractor, getLabeler, learn, save
 
Methods inherited from class LBJ2.classify.Classifier
allowableValues, binaryRead, binaryRead, binaryRead, binaryRead, binaryWrite, binaryWrite, classify, 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

defaultDefaultPrediction

public static final java.lang.String defaultDefaultPrediction
Default for defaultPrediction.


baseLearner

protected Learner baseLearner
Instances of this learning algorithm will be multiplexed; default null.


network

protected java.util.HashMap network
A map from feature values to learners.


defaultPrediction

protected java.lang.String defaultPrediction
This string is returned during testing when the multiplexed Learner doesn't exist; default defaultDefaultPrediction.


select

protected Classifier select
If this classifier's feature extractor is a composite generator, this member variable will reference the first child classifier of that composite generator; otherwise, it is null.


compositeChildren

protected java.util.LinkedList compositeChildren
If this classifier's feature extractor is a composite generator, this list will contain every child classifier of that composite generator except the first; otherwise, it is null.

Constructor Detail

MuxLearner

public MuxLearner()
For the LBJ compiler; not for use by the LBJ user.


MuxLearner

public MuxLearner(Learner base)
Instantiates this multiplexed learner using the specified base learning algorithm. This constructor will normally only be called by the compiler.

Parameters:
base - Instances of this learner will be multiplexed.

MuxLearner

public MuxLearner(Learner base,
                  java.lang.String d)
Instantiates this multiplexed learner using the specified base learning algorithm.

Parameters:
base - Instances of this learner will be multiplexed.
d - This prediction will be returned during testing when the multiplexed Learner does not exist.

MuxLearner

public MuxLearner(MuxLearner.Parameters p)
Initializing constructor. Sets all member variables to their associated settings in the MuxLearner.Parameters object.

Parameters:
p - The settings of all parameters.

MuxLearner

public MuxLearner(java.lang.String n)
For the LBJ compiler; not for use by the LBJ user.


MuxLearner

public MuxLearner(java.lang.String n,
                  Learner base)
Instantiates this multiplexed learner using the specified base learning algorithm.

Parameters:
n - The name of the classifier.
base - Instances of this learner will be multiplexed.

MuxLearner

public MuxLearner(java.lang.String n,
                  Learner base,
                  java.lang.String d)
Instantiates this multiplexed learner using the specified base learning algorithm.

Parameters:
n - The name of the classifier.
base - Instances of this learner will be multiplexed.
d - This prediction will be returned during testing when the multiplexed Learner does not exist.

MuxLearner

public MuxLearner(java.lang.String n,
                  MuxLearner.Parameters p)
Initializing constructor. Sets all member variables to their associated settings in the MuxLearner.Parameters object.

Parameters:
n - The name of the classifier.
p - The settings of all parameters.
Method Detail

setBase

public void setBase(Learner base)
Sets baseLearner. This method will not have any effect on the learners that already exist in the network. However, new learners created after this method is executed will be of the same type as the object specified.

Parameters:
base - The new base learning algorithm.

setLabeler

public void setLabeler(Classifier l)
Sets the labeler.

Overrides:
setLabeler in class Learner
Parameters:
l - A labeling classifier.

setExtractor

public void setExtractor(Classifier e)
Sets the extractor.

Overrides:
setExtractor in class Learner
Parameters:
e - A feature extracting classifier.

learn

public void learn(java.lang.Object example)
The training example is multiplexed to the appropriate Learner(s).

Specified by:
learn in class Learner
Parameters:
example - The example object.

forget

public void forget()
Clears the network.

Specified by:
forget in class Learner

scores

public 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. These scores are just the scores produced by the multiplexed Learner's scores(Object) method.

Specified by:
scores in class Learner
Parameters:
example - The example object.
Returns:
A set of scores indicating the degree to which each possible discrete classification value is associated with the given example object.
See Also:
Learner.scores(Object)

classify

public FeatureVector classify(java.lang.Object example)
This method performs the multiplexing and returns the output of the selected Learner.

Specified by:
classify in class Classifier
Parameters:
example - The example object.
Returns:
The output of the selected Learner.

write

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

Specified by:
write in class Learner
Parameters:
out - The output stream.

clone

public java.lang.Object clone()
Returns a deep clone of this learning algorithm.

Overrides:
clone in class Classifier
Returns:
A shallow clone.