LBJ2.learn
Class AdaBoost

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

public class AdaBoost
extends Learner

Implementation of the AdaBoost binary classification learning algorithm. A Classifier learned with this algorithm will always produce a single Feature with value equal to a value the weak learner is capable of producing. This implementation samples from its internal distribution, giving the weak learner a new set of examples that the weak learner assumes are weighted equally.
Assumptions:

  1. The Learner used as the weak learner is cloneable.
  2. The weak learning algorithm is trained on objects that are each given a single label feature.

See Also:
Serialized Form

Field Summary
private  double[] alpha
          Parameters associated with the trained copies of the weak learner.
protected  int rounds
          The number of times the weak learner will be called.
protected  Learner weakLearner
          The weak learning algorithm to be boosted.
private  Learner[] weakLearners
          Will be filled with trained copies of the weak learner.
 
Fields inherited from class LBJ2.learn.Learner
extractor, labeler
 
Fields inherited from class LBJ2.classify.Classifier
containingPackage, name
 
Constructor Summary
AdaBoost()
          This constructor is used by the LBJ2 compiler; it should never be called by a programmer.
AdaBoost(java.lang.String n, Learner w, int r)
          Instantiates member variables.
 
Method Summary
 FeatureVector classify(java.lang.Object example)
          This method uses the trained parameters to make a binary decision about an example object.
 java.lang.Object clone()
          Returns a deep clone of this learning algorithm.
 void forget()
          Clears weakLearners and alpha, although this is not necessary since learn(Object[]) will overwrite them fresh each time it is called.
 void learn(java.lang.Object e)
          This implementation of AdaBoost cannot be trained in an online fashion, so this method simply reports an error.
 void learn(java.lang.Object[] examples)
          The AdaBoost training algorithm.
 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.
 void write(java.io.PrintStream out)
          Writes this algorithm's internal representation as text.
 
Methods inherited from class LBJ2.learn.Learner
doneLearning, getExtractor, getLabeler, 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

weakLearner

protected Learner weakLearner
The weak learning algorithm to be boosted.


rounds

protected int rounds
The number of times the weak learner will be called.


weakLearners

private Learner[] weakLearners
Will be filled with trained copies of the weak learner.


alpha

private double[] alpha
Parameters associated with the trained copies of the weak learner.

Constructor Detail

AdaBoost

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


AdaBoost

public AdaBoost(java.lang.String n,
                Learner w,
                int r)
Instantiates member variables.

Parameters:
n - The name of the classifier.
w - The weak learning algorithm.
r - The number of rounds of boosting.
Method Detail

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 e)
This implementation of AdaBoost cannot be trained in an online fashion, so this method simply reports an error.

Specified by:
learn in class Learner
Parameters:
e - The parameter will be ignored.

learn

public void learn(java.lang.Object[] examples)
The AdaBoost training algorithm.

Overrides:
learn in class Learner
Parameters:
examples - The entire training set.

forget

public void forget()
Clears weakLearners and alpha, although this is not necessary since learn(Object[]) will overwrite them fresh each time it is called.

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.

Specified by:
scores in class Learner
Parameters:
example - The object to make decisions about.
Returns:
The accumulated alpha values of weak learners that predicted the associated classification value.

classify

public FeatureVector classify(java.lang.Object example)
This method uses the trained parameters to make a binary decision about an example object.

Specified by:
classify in class Classifier
Parameters:
example - The example object.
Returns:
A binary DiscreteFeature.

write

public void write(java.io.PrintStream out)
Writes this 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.