InputType
- The algorithm operates on a
Collection<InputOutputPair<InputType,Boolean>>
. The
InputType
will be something like Vector or String.@CodeReview(reviewer="Kevin R. Dixon", date="2008-07-23", changesNeeded=false, comments={"Added PublicationReference","Cleaned up javadoc a little bit with code annotations.","Otherwise, looks fine."}) @PublicationReference(author={"Yoav Freund","Robert E.Schapire"}, title="A decision-theoretic generalization of on-line learning and an application to boosting", publication="Journal of Computer and System Sciences", notes="Volume 55, Number 1", year=1997, pages={119,139}, type=Journal, url="http://www.cse.ucsd.edu/~yfreund/papers/adaboost.pdf") public class AdaBoost<InputType> extends AbstractAnytimeSupervisedBatchLearner<InputType,java.lang.Boolean,WeightedBinaryEnsemble<InputType,Evaluator<? super InputType,? extends java.lang.Boolean>>> implements BatchLearnerContainer<BatchLearner<? super java.util.Collection<? extends InputOutputPair<? extends InputType,java.lang.Boolean>>,? extends Evaluator<? super InputType,? extends java.lang.Boolean>>>
AdaBoost
class implements the Adaptive Boosting (AdaBoost)
algorithm formulated by Yoav Freund and Robert Shapire. It creates a
weighted binary ensemble as output from the algorithm.Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_MAX_ITERATIONS
The default maximum number of iterations is 100.
|
protected WeightedBinaryEnsemble<InputType,Evaluator<? super InputType,? extends java.lang.Boolean>> |
ensemble
The ensemble learned by the algorithm.
|
protected BatchLearner<? super java.util.Collection<? extends InputOutputPair<? extends InputType,java.lang.Boolean>>,? extends Evaluator<? super InputType,? extends java.lang.Boolean>> |
weakLearner
The "weak learner" that must learn from the weighted input-output pairs
on each iteration.
|
protected java.util.ArrayList<DefaultWeightedInputOutputPair<InputType,java.lang.Boolean>> |
weightedData
An array list containing the weighted version of the data.
|
data, keepGoing
maxIterations
DEFAULT_ITERATION, iteration
Constructor and Description |
---|
AdaBoost()
Creates a new instance of AdaBoost with no base learner.
|
AdaBoost(BatchLearner<? super java.util.Collection<? extends InputOutputPair<? extends InputType,java.lang.Boolean>>,? extends Evaluator<? super InputType,? extends java.lang.Boolean>> weakLearner)
Creates a new instance of AdaBoost.
|
AdaBoost(BatchLearner<? super java.util.Collection<? extends InputOutputPair<? extends InputType,java.lang.Boolean>>,? extends Evaluator<? super InputType,? extends java.lang.Boolean>> weakLearner,
int maxIterations)
Creates a new instance of AdaBoost.
|
Modifier and Type | Method and Description |
---|---|
protected void |
cleanupAlgorithm()
Called to clean up the learning algorithm's state after learning has
finished.
|
WeightedBinaryEnsemble<InputType,Evaluator<? super InputType,? extends java.lang.Boolean>> |
getEnsemble()
Gets the ensemble created by this learner.
|
BatchLearner<? super java.util.Collection<? extends InputOutputPair<? extends InputType,java.lang.Boolean>>,? extends Evaluator<? super InputType,? extends java.lang.Boolean>> |
getLearner()
Gets the learner contained in this object.
|
WeightedBinaryEnsemble<InputType,Evaluator<? super InputType,? extends java.lang.Boolean>> |
getResult()
Gets the current result of the algorithm.
|
BatchLearner<? super java.util.Collection<? extends InputOutputPair<? extends InputType,java.lang.Boolean>>,? extends Evaluator<? super InputType,? extends java.lang.Boolean>> |
getWeakLearner()
Gets the weak learner that is passed the weighted training data on each
step of the algorithm.
|
java.util.ArrayList<DefaultWeightedInputOutputPair<InputType,java.lang.Boolean>> |
getWeightedData()
Gets the weighted version of the data.
|
protected boolean |
initializeAlgorithm()
Called to initialize the learning algorithm's state based on the
data that is stored in the data field.
|
protected void |
setEnsemble(WeightedBinaryEnsemble<InputType,Evaluator<? super InputType,? extends java.lang.Boolean>> ensemble)
Sets the ensemble created by this learner.
|
void |
setWeakLearner(BatchLearner<? super java.util.Collection<? extends InputOutputPair<? extends InputType,java.lang.Boolean>>,? extends Evaluator<? super InputType,? extends java.lang.Boolean>> weakLearner)
Sets the weak learner that is passed the weighted training data on each
step of the algorithm.
|
protected void |
setWeightedData(java.util.ArrayList<DefaultWeightedInputOutputPair<InputType,java.lang.Boolean>> weightedData)
Sets the weighted version of the data.
|
protected boolean |
step()
Called to take a single step of the learning algorithm.
|
clone, getData, getKeepGoing, learn, setData, setKeepGoing, stop
getMaxIterations, isResultValid, setMaxIterations
addIterativeAlgorithmListener, fireAlgorithmEnded, fireAlgorithmStarted, fireStepEnded, fireStepStarted, getIteration, getListeners, removeIterativeAlgorithmListener, setIteration, setListeners
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
learn
clone
getMaxIterations, setMaxIterations
addIterativeAlgorithmListener, getIteration, removeIterativeAlgorithmListener
isResultValid
public static final int DEFAULT_MAX_ITERATIONS
protected BatchLearner<? super java.util.Collection<? extends InputOutputPair<? extends InputType,java.lang.Boolean>>,? extends Evaluator<? super InputType,? extends java.lang.Boolean>> weakLearner
protected transient WeightedBinaryEnsemble<InputType,Evaluator<? super InputType,? extends java.lang.Boolean>> ensemble
protected transient java.util.ArrayList<DefaultWeightedInputOutputPair<InputType,java.lang.Boolean>> weightedData
public AdaBoost()
public AdaBoost(BatchLearner<? super java.util.Collection<? extends InputOutputPair<? extends InputType,java.lang.Boolean>>,? extends Evaluator<? super InputType,? extends java.lang.Boolean>> weakLearner)
weakLearner
- The weak learner to apply learning to on each
iteration.public AdaBoost(BatchLearner<? super java.util.Collection<? extends InputOutputPair<? extends InputType,java.lang.Boolean>>,? extends Evaluator<? super InputType,? extends java.lang.Boolean>> weakLearner, int maxIterations)
weakLearner
- The weak learner to apply learning to on each iteration.maxIterations
- The maximum number of iterations to run for, which is also the
upper bound on the number of learners to create.protected boolean initializeAlgorithm()
AbstractAnytimeBatchLearner
initializeAlgorithm
in class AbstractAnytimeBatchLearner<java.util.Collection<? extends InputOutputPair<? extends InputType,java.lang.Boolean>>,WeightedBinaryEnsemble<InputType,Evaluator<? super InputType,? extends java.lang.Boolean>>>
protected boolean step()
AbstractAnytimeBatchLearner
step
in class AbstractAnytimeBatchLearner<java.util.Collection<? extends InputOutputPair<? extends InputType,java.lang.Boolean>>,WeightedBinaryEnsemble<InputType,Evaluator<? super InputType,? extends java.lang.Boolean>>>
protected void cleanupAlgorithm()
AbstractAnytimeBatchLearner
cleanupAlgorithm
in class AbstractAnytimeBatchLearner<java.util.Collection<? extends InputOutputPair<? extends InputType,java.lang.Boolean>>,WeightedBinaryEnsemble<InputType,Evaluator<? super InputType,? extends java.lang.Boolean>>>
public WeightedBinaryEnsemble<InputType,Evaluator<? super InputType,? extends java.lang.Boolean>> getResult()
AnytimeAlgorithm
getResult
in interface AnytimeAlgorithm<WeightedBinaryEnsemble<InputType,Evaluator<? super InputType,? extends java.lang.Boolean>>>
public BatchLearner<? super java.util.Collection<? extends InputOutputPair<? extends InputType,java.lang.Boolean>>,? extends Evaluator<? super InputType,? extends java.lang.Boolean>> getLearner()
BatchLearnerContainer
getLearner
in interface BatchLearnerContainer<BatchLearner<? super java.util.Collection<? extends InputOutputPair<? extends InputType,java.lang.Boolean>>,? extends Evaluator<? super InputType,? extends java.lang.Boolean>>>
public BatchLearner<? super java.util.Collection<? extends InputOutputPair<? extends InputType,java.lang.Boolean>>,? extends Evaluator<? super InputType,? extends java.lang.Boolean>> getWeakLearner()
public void setWeakLearner(BatchLearner<? super java.util.Collection<? extends InputOutputPair<? extends InputType,java.lang.Boolean>>,? extends Evaluator<? super InputType,? extends java.lang.Boolean>> weakLearner)
weakLearner
- The weak learner for the algorithm to use.public WeightedBinaryEnsemble<InputType,Evaluator<? super InputType,? extends java.lang.Boolean>> getEnsemble()
protected void setEnsemble(WeightedBinaryEnsemble<InputType,Evaluator<? super InputType,? extends java.lang.Boolean>> ensemble)
ensemble
- The ensemble created by this learner.public java.util.ArrayList<DefaultWeightedInputOutputPair<InputType,java.lang.Boolean>> getWeightedData()
protected void setWeightedData(java.util.ArrayList<DefaultWeightedInputOutputPair<InputType,java.lang.Boolean>> weightedData)
weightedData
- The weighted version of the data.