|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.ObjectLBJ2.classify.Classifier
LBJ2.learn.Learner
LBJ2.learn.LinearThresholdUnit
LBJ2.learn.SparsePerceptron
LBJ2.learn.BinaryMIRA
public class BinaryMIRA
The Binary MIRA learning algorithm implementation. This algorithm
operates very similarly to SparsePerceptron with a thick
separator, except the learning rate is a function of each training
example's margin. When the weight vector has made a mistake, the full
SparsePerceptron.learningRate will be used. When the weight
vector did not make a mistake, SparsePerceptron.learningRate is
multiplied by the following value before the update takes place.
(beta/2 - y(w*x)) / ||x||2
In the expression above, w is the weight vector, y represents the label of the example vector x, * stands for inner product, and beta is a user supplied parameter. If this expression turns out to be non-positive (i.e., if y(w*x) >= beta/2), no update is made for that example.
It is assumed that Learner.labeler is a single discrete
classifier that produces the same feature for every example object and
that the values that feature may take are available through the
Classifier.allowableValues() method. The second value returned
from Classifier.allowableValues() is treated as "positive", and it
is assumed there are exactly 2 allowable values. Assertions will produce
error messages if these assumptions do not hold.
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.
| Nested Class Summary | |
|---|---|
static class |
BinaryMIRA.Parameters
Simply a container for all of BinaryMIRA's configurable
parameters. |
| Field Summary | |
|---|---|
protected double |
beta
The user supplied learning algorithm parameter; default defaultBeta. |
static double |
defaultBeta
Default value for beta. |
protected double |
saveLearningRate
A copy of the original learning rate value is stored here so that SparsePerceptron.learningRate can be modified without losing it. |
static double |
TOLERANCE
Used to decide if two values are nearly equal to each other. |
| Fields inherited from class LBJ2.learn.SparsePerceptron |
|---|
defaultLearningRate, learningRate |
| Fields inherited from class LBJ2.learn.LinearThresholdUnit |
|---|
allowableValues, bias, defaultInitialWeight, defaultThickness, defaultThreshold, defaultWeightVector, initialWeight, negativeThickness, positiveThickness, threshold, weightVector |
| Fields inherited from class LBJ2.learn.Learner |
|---|
extractor, labeler |
| Fields inherited from class LBJ2.classify.Classifier |
|---|
containingPackage, name |
| Constructor Summary | |
|---|---|
BinaryMIRA()
The learning rate and beta take default values while the name of the classifier takes the empty string. |
|
BinaryMIRA(BinaryMIRA.Parameters p)
Initializing constructor. |
|
BinaryMIRA(double r)
Sets the learning rate to the specified value, and beta to the default, while the name of the classifier takes the empty string. |
|
BinaryMIRA(double r,
double B)
Sets the learning rate and beta to the specified values, while the name of the classifier takes the empty string. |
|
BinaryMIRA(double r,
double B,
SparseWeightVector v)
Sets the learning rate, beta and the weight vector to the specified values. |
|
BinaryMIRA(java.lang.String n)
Sets the name of the classifier to the specified value, while the learning rate and beta take default values. |
|
BinaryMIRA(java.lang.String n,
BinaryMIRA.Parameters p)
Initializing constructor. |
|
BinaryMIRA(java.lang.String n,
double r)
Sets the name of the classifier and learning rate to the specified values, while beta takes the default value. |
|
BinaryMIRA(java.lang.String n,
double r,
double B)
Sets the name of the classifier, the learning rate and beta to the specified values. |
|
BinaryMIRA(java.lang.String n,
double r,
double B,
SparseWeightVector v)
Sets the name of the classifier, the learning rate, beta and the weight vector to the specified values. |
|
| Method Summary | |
|---|---|
double |
getBeta()
Returns the current value of the beta member variable. |
void |
learn(java.lang.Object example)
Evaluates the example object with the LinearThresholdUnit.score(Object), updates the
learning rate, and finally updates
LinearThresholdUnit.weightVector as described above. |
private static boolean |
nearlyEqualTo(double a,
double b)
Determines if a is nearly equal to b based on
the value of the TOLERANCE member variable. |
void |
setBeta(double B)
Sets the beta member variable to the specified value. |
private void |
updateLearningRate(java.lang.Object example,
double s,
boolean label)
Updates the SparsePerceptron.learningRate member variable. |
void |
write(java.io.PrintStream out)
Writes the algorithm's internal representation as text. |
| Methods inherited from class LBJ2.learn.SparsePerceptron |
|---|
clone, demote, getLearningRate, promote, setLearningRate |
| Methods inherited from class LBJ2.learn.LinearThresholdUnit |
|---|
allowableValues, classify, forget, getInitialWeight, getNegativeThickness, getPositiveThickness, getThreshold, score, scores, setInitialWeight, setLabeler, setNegativeThickness, setPositiveThickness, setThickness, setThreshold |
| Methods inherited from class LBJ2.learn.Learner |
|---|
doneLearning, getExtractor, getLabeler, learn, save, setExtractor |
| Methods inherited from class LBJ2.classify.Classifier |
|---|
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 |
|---|
public static final double TOLERANCE
nearlyEqualTo(double,double),
Constant Field Valuespublic static final double defaultBeta
beta.
protected double beta
defaultBeta. The learning rate changes as a function of
beta.
protected double saveLearningRate
SparsePerceptron.learningRate can be modified without losing it.
| Constructor Detail |
|---|
public BinaryMIRA()
public BinaryMIRA(double r)
r - The desired learning rate value.
public BinaryMIRA(double r,
double B)
r - The desired learning rate value.B - the desired beta value.
public BinaryMIRA(double r,
double B,
SparseWeightVector v)
r - The desired learning rate.B - The desired beta value.v - The desired weight vector.public BinaryMIRA(BinaryMIRA.Parameters p)
BinaryMIRA.Parameters object.
p - The settings of all parameters.public BinaryMIRA(java.lang.String n)
n - The name of the classifier.
public BinaryMIRA(java.lang.String n,
double r)
n - The name of the classifier.r - The desired learning rate.
public BinaryMIRA(java.lang.String n,
double r,
double B)
n - The name of the classifier.r - The desired learning rate.B - The desired beta value.
public BinaryMIRA(java.lang.String n,
double r,
double B,
SparseWeightVector v)
SparseWeightVector.
n - The name of the classifier.r - The desired learning rate.B - The desired beta value.v - The desired weight vector.
public BinaryMIRA(java.lang.String n,
BinaryMIRA.Parameters p)
BinaryMIRA.Parameters object.
n - The name of the classifier.p - The settings of all parameters.| Method Detail |
|---|
public double getBeta()
beta member variable.
beta variable.public void setBeta(double B)
beta member variable to the specified value.
B - The new value for beta.public void learn(java.lang.Object example)
LinearThresholdUnit.score(Object), updates the
learning rate, and finally updates
LinearThresholdUnit.weightVector as described above.
learn in class LinearThresholdUnitexample - The example object
private static boolean nearlyEqualTo(double a,
double b)
a is nearly equal to b based on
the value of the TOLERANCE member variable.
a - The first valueb - The second value
private void updateLearningRate(java.lang.Object example,
double s,
boolean label)
SparsePerceptron.learningRate member variable.
example - The example objects - The score for the example objectlabel - The labelpublic void write(java.io.PrintStream out)
SparsePerceptron.learningRate, beta,
LinearThresholdUnit.initialWeight,
LinearThresholdUnit.threshold,
LinearThresholdUnit.positiveThickness,
LinearThresholdUnit.negativeThickness,
and finally LinearThresholdUnit.bias.
write in class SparsePerceptronout - The output stream.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||