gov.sandia.cognition.learning.algorithm.perceptron.kernel
Class KernelAdatron<InputType>

java.lang.Object
  extended by gov.sandia.cognition.util.AbstractCloneableSerializable
      extended by gov.sandia.cognition.algorithm.AbstractIterativeAlgorithm
          extended by gov.sandia.cognition.algorithm.AbstractAnytimeAlgorithm<ResultType>
              extended by gov.sandia.cognition.learning.algorithm.AbstractAnytimeBatchLearner<Collection<? extends InputOutputPair<? extends InputType,OutputType>>,ResultType>
                  extended by gov.sandia.cognition.learning.algorithm.AbstractAnytimeSupervisedBatchLearner<InputType,Boolean,KernelBinaryCategorizer<InputType,DefaultWeightedValue<InputType>>>
                      extended by gov.sandia.cognition.learning.algorithm.perceptron.kernel.KernelAdatron<InputType>
Type Parameters:
InputType - Input type of the InputOutputPairs
All Implemented Interfaces:
AnytimeAlgorithm<KernelBinaryCategorizer<InputType,DefaultWeightedValue<InputType>>>, IterativeAlgorithm, MeasurablePerformanceAlgorithm, StoppableAlgorithm, AnytimeBatchLearner<Collection<? extends InputOutputPair<? extends InputType,Boolean>>,KernelBinaryCategorizer<InputType,DefaultWeightedValue<InputType>>>, BatchLearner<Collection<? extends InputOutputPair<? extends InputType,Boolean>>,KernelBinaryCategorizer<InputType,DefaultWeightedValue<InputType>>>, SupervisedBatchLearner<InputType,Boolean,KernelBinaryCategorizer<InputType,DefaultWeightedValue<InputType>>>, CloneableSerializable, Serializable, Cloneable

@CodeReview(reviewer="Kevin R. Dixon",
            date="2008-07-23",
            changesNeeded=false,
            comments={"Added PublicationReference to the original article.","Minor changes to javadoc.","Looks fine."})
@PublicationReference(author={"Thilo-Thomas Friess","Nello Cristianini","Colin Campbell"},
                      title="The Kernel-Adatron Algorithm: A Fast and Simple Learning Procedure for Support Vector Machines",
                      type=Conference,
                      publication="Proceedings of the Fifteenth International Conference on Machine Learning",
                      year=1998,
                      pages={188,196})
public class KernelAdatron<InputType>
extends AbstractAnytimeSupervisedBatchLearner<InputType,Boolean,KernelBinaryCategorizer<InputType,DefaultWeightedValue<InputType>>>
implements MeasurablePerformanceAlgorithm

The KernelAdatron class implements an online version of the Support Vector Machine learning algorithm. It is based on an extension of the Perceptron algorithm.

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

Field Summary
static int DEFAULT_MAX_ITERATIONS
          The default maximum number of iterations, 100.
 
Fields inherited from class gov.sandia.cognition.learning.algorithm.AbstractAnytimeBatchLearner
data, keepGoing
 
Fields inherited from class gov.sandia.cognition.algorithm.AbstractAnytimeAlgorithm
maxIterations
 
Fields inherited from class gov.sandia.cognition.algorithm.AbstractIterativeAlgorithm
DEFAULT_ITERATION, iteration
 
Constructor Summary
KernelAdatron()
          Creates a new instance of KernelAdatron.
KernelAdatron(Kernel<? super InputType> kernel)
          Creates a new KernelAdatron with the given kernel.
KernelAdatron(Kernel<? super InputType> kernel, int maxIterations)
          Creates a new KernelAdatron with the given kernel and maximum number of iterations.
 
Method Summary
protected  void cleanupAlgorithm()
          Called to clean up the learning algorithm's state after learning has finished.
 int getErrorCount()
          Gets the error count of the most recent iteration.
 Kernel<? super InputType> getKernel()
          Gets the kernel to use.
 NamedValue<Integer> getPerformance()
          Gets the name-value pair that describes the current performance of the algorithm.
 KernelBinaryCategorizer<InputType,DefaultWeightedValue<InputType>> getResult()
          Gets the current result of the algorithm.
protected  LinkedHashMap<InputOutputPair<? extends InputType,Boolean>,DefaultWeightedValue<InputType>> getSupportsMap()
          Gets the mapping of examples to weight objects (support vectors).
protected  boolean initializeAlgorithm()
          Called to initialize the learning algorithm's state based on the data that is stored in the data field.
protected  void setErrorCount(int errorCount)
          Sets the error count of the most recent iteration.
 void setKernel(Kernel<? super InputType> kernel)
          Sets the kernel to use.
protected  void setLearned(KernelBinaryCategorizer<InputType,DefaultWeightedValue<InputType>> result)
          Sets the object currently being result.
protected  void setSupportsMap(LinkedHashMap<InputOutputPair<? extends InputType,Boolean>,DefaultWeightedValue<InputType>> supportsMap)
          Gets the mapping of examples to weight objects (support vectors).
protected  boolean step()
          Called to take a single step of the learning algorithm.
 
Methods inherited from class gov.sandia.cognition.learning.algorithm.AbstractAnytimeBatchLearner
clone, getData, getKeepGoing, learn, setData, setKeepGoing, stop
 
Methods inherited from class gov.sandia.cognition.algorithm.AbstractAnytimeAlgorithm
getMaxIterations, isResultValid, setMaxIterations
 
Methods inherited from class gov.sandia.cognition.algorithm.AbstractIterativeAlgorithm
addIterativeAlgorithmListener, fireAlgorithmEnded, fireAlgorithmStarted, fireStepEnded, fireStepStarted, getIteration, getListeners, removeIterativeAlgorithmListener, setIteration, setListeners
 
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.BatchLearner
learn
 
Methods inherited from interface gov.sandia.cognition.util.CloneableSerializable
clone
 
Methods inherited from interface gov.sandia.cognition.algorithm.AnytimeAlgorithm
getMaxIterations, setMaxIterations
 
Methods inherited from interface gov.sandia.cognition.algorithm.IterativeAlgorithm
addIterativeAlgorithmListener, getIteration, removeIterativeAlgorithmListener
 
Methods inherited from interface gov.sandia.cognition.algorithm.StoppableAlgorithm
isResultValid
 

Field Detail

DEFAULT_MAX_ITERATIONS

public static final int DEFAULT_MAX_ITERATIONS
The default maximum number of iterations, 100.

See Also:
Constant Field Values
Constructor Detail

KernelAdatron

public KernelAdatron()
Creates a new instance of KernelAdatron.


KernelAdatron

public KernelAdatron(Kernel<? super InputType> kernel)
Creates a new KernelAdatron with the given kernel.

Parameters:
kernel - The kernel to use.

KernelAdatron

public KernelAdatron(Kernel<? super InputType> kernel,
                     int maxIterations)
Creates a new KernelAdatron with the given kernel and maximum number of iterations.

Parameters:
kernel - The kernel to use.
maxIterations - The maximum number of iterations.
Method Detail

initializeAlgorithm

protected boolean initializeAlgorithm()
Description copied from class: AbstractAnytimeBatchLearner
Called to initialize the learning algorithm's state based on the data that is stored in the data field. The return value indicates if the algorithm can be run or not based on the initialization.

Specified by:
initializeAlgorithm in class AbstractAnytimeBatchLearner<Collection<? extends InputOutputPair<? extends InputType,Boolean>>,KernelBinaryCategorizer<InputType,DefaultWeightedValue<InputType>>>
Returns:
True if the learning algorithm can be run and false if it cannot.

step

protected boolean step()
Description copied from class: AbstractAnytimeBatchLearner
Called to take a single step of the learning algorithm.

Specified by:
step in class AbstractAnytimeBatchLearner<Collection<? extends InputOutputPair<? extends InputType,Boolean>>,KernelBinaryCategorizer<InputType,DefaultWeightedValue<InputType>>>
Returns:
True if another step can be taken and false it the algorithm should halt.

cleanupAlgorithm

protected void cleanupAlgorithm()
Description copied from class: AbstractAnytimeBatchLearner
Called to clean up the learning algorithm's state after learning has finished.

Specified by:
cleanupAlgorithm in class AbstractAnytimeBatchLearner<Collection<? extends InputOutputPair<? extends InputType,Boolean>>,KernelBinaryCategorizer<InputType,DefaultWeightedValue<InputType>>>

getKernel

public Kernel<? super InputType> getKernel()
Gets the kernel to use.

Returns:
The kernel to use.

setKernel

public void setKernel(Kernel<? super InputType> kernel)
Sets the kernel to use.

Parameters:
kernel - The kernel to use.

getResult

public KernelBinaryCategorizer<InputType,DefaultWeightedValue<InputType>> getResult()
Description copied from interface: AnytimeAlgorithm
Gets the current result of the algorithm.

Specified by:
getResult in interface AnytimeAlgorithm<KernelBinaryCategorizer<InputType,DefaultWeightedValue<InputType>>>
Returns:
Current result of the algorithm.

setLearned

protected void setLearned(KernelBinaryCategorizer<InputType,DefaultWeightedValue<InputType>> result)
Sets the object currently being result.

Parameters:
result - The object currently being result.

getErrorCount

public int getErrorCount()
Gets the error count of the most recent iteration.

Returns:
The current error count.

setErrorCount

protected void setErrorCount(int errorCount)
Sets the error count of the most recent iteration.

Parameters:
errorCount - The current error count.

getSupportsMap

protected LinkedHashMap<InputOutputPair<? extends InputType,Boolean>,DefaultWeightedValue<InputType>> getSupportsMap()
Gets the mapping of examples to weight objects (support vectors).

Returns:
The mapping of examples to weight objects.

setSupportsMap

protected void setSupportsMap(LinkedHashMap<InputOutputPair<? extends InputType,Boolean>,DefaultWeightedValue<InputType>> supportsMap)
Gets the mapping of examples to weight objects (support vectors).

Parameters:
supportsMap - The mapping of examples to weight objects.

getPerformance

public NamedValue<Integer> getPerformance()
Description copied from interface: MeasurablePerformanceAlgorithm
Gets the name-value pair that describes the current performance of the algorithm. For most algorithms, this is the value that they are attempting to optimize.

Specified by:
getPerformance in interface MeasurablePerformanceAlgorithm
Returns:
The name-value pair that describes the current performance of the algorithm.