public class AdaBoost extends Learner
Assumptions:
Modifier and Type | Class and Description |
---|---|
static class |
AdaBoost.Parameters
A container for all of
AdaBoost 's configurable parameters. |
Modifier and Type | Field and Description |
---|---|
protected edu.illinois.cs.cogcomp.core.datastructures.vectors.OVector |
allExamples
All the examples observed by this learner during training.
|
protected String[] |
allowableValues
The label producing classifier's allowable values.
|
protected double[] |
alpha
Parameters associated with the trained copies of the weak learner.
|
static int |
defaultRounds
Default for
rounds . |
static Learner |
defaultWeakLearner
Default for
weakLearner . |
protected int |
rounds
The number of times the weak learner will be called.
|
protected Learner |
weakLearner
The weak learning algorithm to be boosted.
|
protected Learner[] |
weakLearners
Will be filled with trained copies of the weak learner.
|
candidates, encoding, extractor, labeler, labelLexicon, lcFilePath, lexFilePath, lexicon, lossFlag, predictions, readLexiconOnDemand
containingPackage, name
Constructor and Description |
---|
AdaBoost()
Instantiates member variables.
|
AdaBoost(AdaBoost.Parameters p)
Initializing constructor.
|
AdaBoost(int r)
Instantiates member variables.
|
AdaBoost(Learner w)
Instantiates member variables.
|
AdaBoost(Learner w,
int r)
Instantiates member variables.
|
AdaBoost(String n)
Instantiates member variables.
|
AdaBoost(String n,
AdaBoost.Parameters p)
Initializing constructor.
|
AdaBoost(String n,
int r)
Instantiates member variables.
|
AdaBoost(String n,
Learner w)
Instantiates member variables.
|
AdaBoost(String n,
Learner w,
int r)
Instantiates member variables.
|
Modifier and Type | Method and Description |
---|---|
String[] |
allowableValues()
Returns the array of allowable values that a feature returned by this classifier may take.
|
FeatureVector |
classify(int[] exampleFeatures,
double[] exampleValues)
This method uses the trained parameters to make a binary decision about an example object.
|
String |
discreteValue(int[] exampleFeatures,
double[] exampleValues)
This method uses the trained parameters to make a binary decision about an example object.
|
void |
doneLearning()
Performs learning on the examples stored in
allExamples , if they exist; otherwise do
nothing. |
Feature |
featureValue(int[] exampleFeatures,
double[] exampleValues)
Returns the classification of the given example as a single feature instead of a
FeatureVector . |
void |
forget()
Clears
weakLearners and alpha , although this is not necessary since
learn(Object[]) will overwrite them fresh each time it is called. |
Learner.Parameters |
getParameters()
Retrieves the parameters that are set in this learner.
|
void |
initialize(int numExamples,
int numFeatures)
Initializes the weight vector array to the size of the supplied number of features.
|
void |
learn(int[] exampleFeatures,
double[] exampleValues,
int[] exampleLabels,
double[] labelValues)
This method adds the example object to the array storing the training examples.
|
void |
learn(Object example)
This method adds the example object to the array storing the training examples.
|
void |
read(edu.illinois.cs.cogcomp.core.datastructures.vectors.ExceptionlessInputStream in)
Reads the binary representation of a learner with this object's run-time type, overwriting
any and all learned or manually specified parameters as well as the label lexicon but without
modifying the feature lexicon.
|
ScoreSet |
scores(int[] exampleFeatures,
double[] exampleValues)
Produces a set of scores indicating the degree to which each possible discrete classification
value is associated with the given example object.
|
void |
setLabeler(Classifier l)
Sets the labeler.
|
void |
setParameters(AdaBoost.Parameters p)
Sets the values of parameters that control the behavior of this learning algorithm.
|
protected double[] |
sumAlphas(int[] exampleFeatures,
double[] exampleValues)
Computes the scores corresponding to the two prediction values for the given example.
|
void |
write(edu.illinois.cs.cogcomp.core.datastructures.vectors.ExceptionlessOutputStream out)
Writes the learned function's internal representation in binary form.
|
void |
write(PrintStream out)
Writes this algorithm's internal representation as text.
|
classify, classify, classify, classify, clone, countFeatures, createPrediction, createPrediction, demandLexicon, discreteValue, discreteValue, doneWithRound, emptyClone, featureValue, featureValue, getCurrentLexicon, getExampleArray, getExampleArray, getExtractor, getLabeler, getLabelLexicon, getLexicon, getLexiconDiscardCounts, getLexiconLocation, getModelLocation, getPrunedLexiconSize, learn, learn, learn, read, readLabelLexicon, readLearner, readLearner, readLearner, readLearner, readLearner, readLearner, readLexicon, readLexicon, readLexiconOnDemand, readLexiconOnDemand, readModel, readModel, readParameters, realValue, realValue, realValue, save, saveLexicon, saveModel, scores, scores, scoresAugmented, setCandidates, setEncoding, setExtractor, setLabelLexicon, setLexicon, setLexiconLocation, setLexiconLocation, setLossFlag, setModelLocation, setModelLocation, setParameters, setReadLexiconOnDemand, unclone, unsetLossFlag, write, writeLexicon, writeModel, writeParameters
classify, discreteValueArray, getCompositeChildren, getInputType, getOutputType, realValueArray, test, toString, valueIndexOf
public static final Learner defaultWeakLearner
weakLearner
.public static final int defaultRounds
rounds
.protected Learner weakLearner
protected int rounds
protected Learner[] weakLearners
protected double[] alpha
protected edu.illinois.cs.cogcomp.core.datastructures.vectors.OVector allExamples
protected String[] allowableValues
public AdaBoost()
public AdaBoost(Learner w)
w
- The weak learning algorithm.public AdaBoost(int r)
r
- The number of rounds of boosting.public AdaBoost(Learner w, int r)
w
- The weak learning algorithm.r
- The number of rounds of boosting.public AdaBoost(AdaBoost.Parameters p)
AdaBoost.Parameters
object.p
- The settings of all parameters.public AdaBoost(String n)
n
- The name of the classifier.public AdaBoost(String n, Learner w)
n
- The name of the classifier.w
- The weak learning algorithm.public AdaBoost(String n, int r)
n
- The name of the classifier.r
- The number of rounds of boosting.public AdaBoost(String n, Learner w, int r)
n
- The name of the classifier.w
- The weak learning algorithm.r
- The number of rounds of boosting.public AdaBoost(String n, AdaBoost.Parameters p)
AdaBoost.Parameters
object.n
- The name of the classifier.p
- The settings of all parameters.public void setParameters(AdaBoost.Parameters p)
p
- The parameters.public Learner.Parameters getParameters()
getParameters
in class Learner
public String[] allowableValues()
allowableValues
in class Classifier
public void setLabeler(Classifier l)
setLabeler
in class Learner
l
- A labeling classifier.public void initialize(int numExamples, int numFeatures)
initialize
in class Learner
numExamples
- The number of examples that will be observed during training.numFeatures
- The number of features that will be observed during training.public void learn(Object example)
Note that learning does not actually take place until doneLearning()
is called.
public void learn(int[] exampleFeatures, double[] exampleValues, int[] exampleLabels, double[] labelValues)
Note that learning does not actually take place until doneLearning()
is called.
public void doneLearning()
allExamples
, if they exist; otherwise do
nothing.doneLearning
in class Learner
public void forget()
weakLearners
and alpha
, although this is not necessary since
learn(Object[])
will overwrite them fresh each time it is called.protected double[] sumAlphas(int[] exampleFeatures, double[] exampleValues)
exampleFeatures
- The example's array of feature indices.exampleValues
- The example's array of feature values.Learner.labelLexicon
in an array with
the same indexes.public ScoreSet scores(int[] exampleFeatures, double[] exampleValues)
public Feature featureValue(int[] exampleFeatures, double[] exampleValues)
FeatureVector
.featureValue
in class Learner
exampleFeatures
- The example's array of feature indices.exampleValues
- The example's array of feature values.public String discreteValue(int[] exampleFeatures, double[] exampleValues)
discreteValue
in class Learner
exampleFeatures
- The example's array of feature indices.exampleValues
- The example's array of feature values.public FeatureVector classify(int[] exampleFeatures, double[] exampleValues)
public void write(PrintStream out)
public void write(edu.illinois.cs.cogcomp.core.datastructures.vectors.ExceptionlessOutputStream out)
public void read(edu.illinois.cs.cogcomp.core.datastructures.vectors.ExceptionlessInputStream in)
Copyright © 2016. All rights reserved.