gov.sandia.cognition.learning.algorithm.perceptron
Class OnlineBinaryMarginInfusedRelaxedAlgorithm

java.lang.Object
  extended by gov.sandia.cognition.util.AbstractCloneableSerializable
      extended by gov.sandia.cognition.learning.algorithm.AbstractBatchAndIncrementalLearner<InputOutputPair<? extends InputType,OutputType>,ResultType>
          extended by gov.sandia.cognition.learning.algorithm.AbstractSupervisedBatchAndIncrementalLearner<Vectorizable,Boolean,LinearBinaryCategorizer>
              extended by gov.sandia.cognition.learning.algorithm.perceptron.AbstractOnlineLinearBinaryCategorizerLearner
                  extended by gov.sandia.cognition.learning.algorithm.perceptron.AbstractKernelizableBinaryCategorizerOnlineLearner
                      extended by gov.sandia.cognition.learning.algorithm.perceptron.AbstractLinearCombinationOnlineLearner
                          extended by gov.sandia.cognition.learning.algorithm.perceptron.OnlineBinaryMarginInfusedRelaxedAlgorithm
All Implemented Interfaces:
BatchAndIncrementalLearner<InputOutputPair<? extends Vectorizable,Boolean>,LinearBinaryCategorizer>, BatchLearner<Collection<? extends InputOutputPair<? extends Vectorizable,Boolean>>,LinearBinaryCategorizer>, IncrementalLearner<InputOutputPair<? extends Vectorizable,Boolean>,LinearBinaryCategorizer>, KernelizableBinaryCategorizerOnlineLearner, SupervisedBatchAndIncrementalLearner<Vectorizable,Boolean,LinearBinaryCategorizer>, SupervisedBatchLearner<Vectorizable,Boolean,LinearBinaryCategorizer>, SupervisedIncrementalLearner<Vectorizable,Boolean,LinearBinaryCategorizer>, VectorFactoryContainer, CloneableSerializable, Serializable, Cloneable

@PublicationReference(author={"Koby Crammer","Yoram Singer"},
                      title="Ultraconservative Online Algorithms for Multiclass Problems",
                      year=2003,
                      type=Journal,
                      publication="Journal of Machine Learning Research",
                      pages={951,991},
                      url="http://portal.acm.org/citation.cfm?id=944936")
public class OnlineBinaryMarginInfusedRelaxedAlgorithm
extends AbstractLinearCombinationOnlineLearner

An implementation of the binary MIRA algorithm.

Since:
3.3.0
Author:
Justin Basilico
See Also:
Serialized Form

Field Summary
static double DEFAULT_MIN_MARGIN
          The default minimum margin is 0.0.
static boolean DEFAULT_UPDATE_BIAS
          MIRA does not use a bias by default.
protected  double minMargin
          The minimum margin to enforce.
 
Fields inherited from class gov.sandia.cognition.learning.algorithm.perceptron.AbstractLinearCombinationOnlineLearner
updateBias
 
Fields inherited from class gov.sandia.cognition.learning.algorithm.perceptron.AbstractOnlineLinearBinaryCategorizerLearner
vectorFactory
 
Constructor Summary
OnlineBinaryMarginInfusedRelaxedAlgorithm()
          Creates a new OnlineBinaryMarginInfusedRelaxedAlgorithm with default parameters.
OnlineBinaryMarginInfusedRelaxedAlgorithm(double minMargin)
          Creates a new OnlineBinaryMarginInfusedRelaxedAlgorithm with the given minimum margin.
OnlineBinaryMarginInfusedRelaxedAlgorithm(double minMargin, VectorFactory<?> vectorFactory)
          Creates a new OnlineBinaryMarginInfusedRelaxedAlgorithm with the new minimum margin.
 
Method Summary
protected
<InputType>
double
computeUpdate(DefaultKernelBinaryCategorizer<InputType> target, InputType input, boolean actualCategory, double predicted)
          Compute the update weight in the linear case.
protected  double computeUpdate(LinearBinaryCategorizer target, Vector input, boolean actualCategory, double predicted)
          Compute the update weight in the linear case.
 double getMinMargin()
          Gets the minimum margin to enforce.
protected
<InputType>
void
initialize(DefaultKernelBinaryCategorizer<InputType> target, InputType input, boolean actualCategory)
          Initializes the kernel binary categorizer.
protected  void initialize(LinearBinaryCategorizer target, Vector input, boolean actualCategory)
          Initializes the linear binary categorizer.
 void setMinMargin(double minMargin)
          Gets the minimum margin to enforce.
 
Methods inherited from class gov.sandia.cognition.learning.algorithm.perceptron.AbstractLinearCombinationOnlineLearner
computeDecay, computeDecay, computeRescaling, computeRescaling, createInitialLearnedObject, isUpdateBias, setUpdateBias, update, update
 
Methods inherited from class gov.sandia.cognition.learning.algorithm.perceptron.AbstractKernelizableBinaryCategorizerOnlineLearner
createKernelLearner, learn, update, update, update
 
Methods inherited from class gov.sandia.cognition.learning.algorithm.perceptron.AbstractOnlineLinearBinaryCategorizerLearner
createInitialLearnedObject, getVectorFactory, setVectorFactory, update
 
Methods inherited from class gov.sandia.cognition.learning.algorithm.AbstractSupervisedBatchAndIncrementalLearner
update
 
Methods inherited from class gov.sandia.cognition.learning.algorithm.AbstractBatchAndIncrementalLearner
clone, learn, learn, update
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface gov.sandia.cognition.learning.algorithm.SupervisedIncrementalLearner
update
 
Methods inherited from interface gov.sandia.cognition.learning.algorithm.BatchAndIncrementalLearner
learn
 
Methods inherited from interface gov.sandia.cognition.learning.algorithm.BatchLearner
learn
 
Methods inherited from interface gov.sandia.cognition.learning.algorithm.IncrementalLearner
createInitialLearnedObject, update, update
 
Methods inherited from interface gov.sandia.cognition.util.CloneableSerializable
clone
 

Field Detail

DEFAULT_UPDATE_BIAS

public static final boolean DEFAULT_UPDATE_BIAS
MIRA does not use a bias by default.

See Also:
Constant Field Values

DEFAULT_MIN_MARGIN

public static final double DEFAULT_MIN_MARGIN
The default minimum margin is 0.0.

See Also:
Constant Field Values

minMargin

protected double minMargin
The minimum margin to enforce. Must be non-negative.

Constructor Detail

OnlineBinaryMarginInfusedRelaxedAlgorithm

public OnlineBinaryMarginInfusedRelaxedAlgorithm()
Creates a new OnlineBinaryMarginInfusedRelaxedAlgorithm with default parameters.


OnlineBinaryMarginInfusedRelaxedAlgorithm

public OnlineBinaryMarginInfusedRelaxedAlgorithm(double minMargin)
Creates a new OnlineBinaryMarginInfusedRelaxedAlgorithm with the given minimum margin.

Parameters:
minMargin - The minimum margin to enforce. Must be non-negative.

OnlineBinaryMarginInfusedRelaxedAlgorithm

public OnlineBinaryMarginInfusedRelaxedAlgorithm(double minMargin,
                                                 VectorFactory<?> vectorFactory)
Creates a new OnlineBinaryMarginInfusedRelaxedAlgorithm with the new minimum margin.

Parameters:
minMargin - The minimum margin to enforce. Must be non-negative.
vectorFactory - The factory to use to create vectors.
Method Detail

getMinMargin

public double getMinMargin()
Gets the minimum margin to enforce. Any value less than or equal to this is considered an error for the algorithm.

Returns:
The minimum margin. Cannot be negative.

setMinMargin

public void setMinMargin(double minMargin)
Gets the minimum margin to enforce. Any value less than or equal to this is considered an error for the algorithm.

Parameters:
minMargin - The minimum margin. Cannot be negative.

initialize

protected void initialize(LinearBinaryCategorizer target,
                          Vector input,
                          boolean actualCategory)
Description copied from class: AbstractLinearCombinationOnlineLearner
Initializes the linear binary categorizer. Can be overridden. The default implementation just sets the weights to the zero vector.

Overrides:
initialize in class AbstractLinearCombinationOnlineLearner
Parameters:
target - The categorizer to initialize.
input - The first input seen.
actualCategory - The actual category of the first input.

computeUpdate

protected double computeUpdate(LinearBinaryCategorizer target,
                               Vector input,
                               boolean actualCategory,
                               double predicted)
Description copied from class: AbstractLinearCombinationOnlineLearner
Compute the update weight in the linear case. Must be implemented by subclasses.

Specified by:
computeUpdate in class AbstractLinearCombinationOnlineLearner
Parameters:
target - Target to compute the update for.
input - Input to use in computing the update.
actualCategory - The actual category of the input.
predicted - The predicted category of the input.
Returns:
The update weight for how much to add the input to the target. May be zero if no update is needed.

initialize

protected <InputType> void initialize(DefaultKernelBinaryCategorizer<InputType> target,
                                      InputType input,
                                      boolean actualCategory)
Description copied from class: AbstractLinearCombinationOnlineLearner
Initializes the kernel binary categorizer. Can be overridden. The default implementation does nothing.

Overrides:
initialize in class AbstractLinearCombinationOnlineLearner
Type Parameters:
InputType - The input value for learning.
Parameters:
target - The categorizer to initialize.
input - The first input seen.
actualCategory - The actual category of the first input.

computeUpdate

protected <InputType> double computeUpdate(DefaultKernelBinaryCategorizer<InputType> target,
                                           InputType input,
                                           boolean actualCategory,
                                           double predicted)
Description copied from class: AbstractLinearCombinationOnlineLearner
Compute the update weight in the linear case. Must be implemented by subclasses.

Specified by:
computeUpdate in class AbstractLinearCombinationOnlineLearner
Type Parameters:
InputType - The input value for learning.
Parameters:
target - Target to compute the update for.
input - Input to use in computing the update.
actualCategory - The actual category of the input.
predicted - The predicted category of the input.
Returns:
The update weight for how much to add the input to the target. May be zero if no update is needed.