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

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,WeightedBinaryEnsemble<Vectorizable,LinearBinaryCategorizer>>
              extended by gov.sandia.cognition.learning.algorithm.perceptron.OnlineVotedPerceptron
All Implemented Interfaces:
BatchAndIncrementalLearner<InputOutputPair<? extends Vectorizable,Boolean>,WeightedBinaryEnsemble<Vectorizable,LinearBinaryCategorizer>>, BatchLearner<Collection<? extends InputOutputPair<? extends Vectorizable,Boolean>>,WeightedBinaryEnsemble<Vectorizable,LinearBinaryCategorizer>>, IncrementalLearner<InputOutputPair<? extends Vectorizable,Boolean>,WeightedBinaryEnsemble<Vectorizable,LinearBinaryCategorizer>>, SupervisedBatchAndIncrementalLearner<Vectorizable,Boolean,WeightedBinaryEnsemble<Vectorizable,LinearBinaryCategorizer>>, SupervisedBatchLearner<Vectorizable,Boolean,WeightedBinaryEnsemble<Vectorizable,LinearBinaryCategorizer>>, SupervisedIncrementalLearner<Vectorizable,Boolean,WeightedBinaryEnsemble<Vectorizable,LinearBinaryCategorizer>>, VectorFactoryContainer, CloneableSerializable, Serializable, Cloneable

@PublicationReference(title="Large Margin Classification Using the Perceptron Algorithm",
                      author={"Yoav Freund","Robert E. Schapire"},
                      year=1999,
                      type=Journal,
                      publication="Machine Learning",
                      pages={277,296},
                      url="http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.48.8200")
public class OnlineVotedPerceptron
extends AbstractSupervisedBatchAndIncrementalLearner<Vectorizable,Boolean,WeightedBinaryEnsemble<Vectorizable,LinearBinaryCategorizer>>
implements VectorFactoryContainer

An online version of the Voted-Perceptron algorithm. It is similar to the typical Perceptron algorithm except that it creates multiple Perceptrons, and combines them together in a weighted vote. Whenever a mistake is made, a new Perceptron is created by modifying the previous one and given a weight of 1. When it gets an example correct, it simply increments the weight on the most recent one.

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

Field Summary
protected  VectorFactory<?> vectorFactory
          The factory to create weight vectors.
 
Constructor Summary
OnlineVotedPerceptron()
          Creates a new OnlinePerceptron.
OnlineVotedPerceptron(VectorFactory<?> vectorFactory)
          Creates a new OnlinePerceptron with the given vector factory.
 
Method Summary
 WeightedBinaryEnsemble<Vectorizable,LinearBinaryCategorizer> createInitialLearnedObject()
          Creates a new initial learned object, before any data is given.
static DefaultWeightedValue<LinearBinaryCategorizer> getLastMember(WeightedBinaryEnsemble<Vectorizable,LinearBinaryCategorizer> ensemble)
          Gets the last member in the ensemble.
 VectorFactory<?> getVectorFactory()
          Gets the VectorFactory used to create the weight vector.
 void setVectorFactory(VectorFactory<?> vectorFactory)
          Sets the VectorFactory used to create the weight vector.
 void update(WeightedBinaryEnsemble<Vectorizable,LinearBinaryCategorizer> target, Vector input, boolean actual)
          The update method updates an object of ResultType using the given a new supervised input-output pair, using some form of "learning" algorithm.
 void update(WeightedBinaryEnsemble<Vectorizable,LinearBinaryCategorizer> target, Vectorizable input, Boolean output)
          The update method updates an object of ResultType using the given a new supervised input-output pair, using some form of "learning" algorithm.
 
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.BatchAndIncrementalLearner
learn
 
Methods inherited from interface gov.sandia.cognition.learning.algorithm.BatchLearner
learn
 
Methods inherited from interface gov.sandia.cognition.learning.algorithm.IncrementalLearner
update
 
Methods inherited from interface gov.sandia.cognition.util.CloneableSerializable
clone
 

Field Detail

vectorFactory

protected VectorFactory<?> vectorFactory
The factory to create weight vectors.

Constructor Detail

OnlineVotedPerceptron

public OnlineVotedPerceptron()
Creates a new OnlinePerceptron.


OnlineVotedPerceptron

public OnlineVotedPerceptron(VectorFactory<?> vectorFactory)
Creates a new OnlinePerceptron with the given vector factory.

Parameters:
vectorFactory - The vector factory to use to create the weight vectors.
Method Detail

createInitialLearnedObject

public WeightedBinaryEnsemble<Vectorizable,LinearBinaryCategorizer> createInitialLearnedObject()
Description copied from interface: IncrementalLearner
Creates a new initial learned object, before any data is given.

Specified by:
createInitialLearnedObject in interface IncrementalLearner<InputOutputPair<? extends Vectorizable,Boolean>,WeightedBinaryEnsemble<Vectorizable,LinearBinaryCategorizer>>
Returns:
The initial learned object.

update

public void update(WeightedBinaryEnsemble<Vectorizable,LinearBinaryCategorizer> target,
                   Vectorizable input,
                   Boolean output)
Description copied from interface: SupervisedIncrementalLearner
The update method updates an object of ResultType using the given a new supervised input-output pair, using some form of "learning" algorithm.

Specified by:
update in interface SupervisedIncrementalLearner<Vectorizable,Boolean,WeightedBinaryEnsemble<Vectorizable,LinearBinaryCategorizer>>
Parameters:
target - The object to update.
input - The supervised input to learn from.
output - The supervised output to learn from.

update

public void update(WeightedBinaryEnsemble<Vectorizable,LinearBinaryCategorizer> target,
                   Vector input,
                   boolean actual)
The update method updates an object of ResultType using the given a new supervised input-output pair, using some form of "learning" algorithm.

Parameters:
target - The object to update.
input - The supervised input vector to learn from.
actual - The supervised output label to learn from.

getLastMember

public static DefaultWeightedValue<LinearBinaryCategorizer> getLastMember(WeightedBinaryEnsemble<Vectorizable,LinearBinaryCategorizer> ensemble)
Gets the last member in the ensemble. This is the one used by the algorithm.

Parameters:
ensemble - The ensemble to get the last member from.
Returns:
The last member in the ensemble, or null if it is empty.

getVectorFactory

public VectorFactory<?> getVectorFactory()
Gets the VectorFactory used to create the weight vector.

Specified by:
getVectorFactory in interface VectorFactoryContainer
Returns:
The VectorFactory used to create the weight vector.

setVectorFactory

public void setVectorFactory(VectorFactory<?> vectorFactory)
Sets the VectorFactory used to create the weight vector.

Parameters:
vectorFactory - The VectorFactory used to create the weight vector.