InputType - Input class of the InputOutputPairs@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={"Yoav Freund","Robert E. Schapire"}, title="Large margin classification using the perceptron algorithm", publication="Machine Learning", type=Journal, year=1999, notes="Volume 37, Number 3", pages={277,296}, url="http://www.cs.ucsd.edu/~yfreund/papers/LargeMarginsUsingPerceptron.pdf") public class KernelPerceptron<InputType> extends AbstractAnytimeSupervisedBatchLearner<InputType,java.lang.Boolean,DefaultKernelBinaryCategorizer<InputType>> implements MeasurablePerformanceAlgorithm
KernelPerceptron class implements the kernel version of 
 the Perceptron algorithm. That is, it replaces the inner-product used in the 
 standard Perceptron algorithm with a kernel method. This allows the 
 algorithm to be used with data and a kernel that would map it into a 
 high-dimensional space but does not need to since the kernel can compute the 
 inner-product in the high-dimensional space without actually creating the 
 vectors for it.Perceptron, 
Serialized Form| Modifier and Type | Field and Description | 
|---|---|
| static double | DEFAULT_MARGIN_NEGATIVEThe default negative margin, 0.0. | 
| static double | DEFAULT_MARGIN_POSITIVEThe default positive margin, 0.0. | 
| static int | DEFAULT_MAX_ITERATIONSThe default maximum number of iterations, 100. | 
data, keepGoingmaxIterationsDEFAULT_ITERATION, iteration| Constructor and Description | 
|---|
| KernelPerceptron()Creates a new instance of KernelPerceptron. | 
| KernelPerceptron(Kernel<? super InputType> kernel)Creates a new KernelPerceptron with the given kernel. | 
| KernelPerceptron(Kernel<? super InputType> kernel,
                int maxIterations)Creates a new KernelPerceptron with the given kernel and maximum number
 of iterations. | 
| KernelPerceptron(Kernel<? super InputType> kernel,
                int maxIterations,
                double marginPositive,
                double marginNegative)Creates a new KernelPerceptron with the given parameters. | 
| Modifier and Type | Method and Description | 
|---|---|
| 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. | 
| double | getMarginNegative()Gets the negative margin that is enforced. | 
| double | getMarginPositive()Gets the positive margin that is enforced. | 
| NamedValue<java.lang.Integer> | getPerformance()Gets the name-value pair that describes the current performance of the
 algorithm. | 
| DefaultKernelBinaryCategorizer<InputType> | getResult()Gets the current result of the algorithm. | 
| protected java.util.LinkedHashMap<InputOutputPair<? extends InputType,? extends java.lang.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. | 
| void | setMargin(double margin)Sets both the positive and negative margin to the same value. | 
| void | setMarginNegative(double marginNegative)Sets the negative margin that is enforced. | 
| void | setMarginPositive(double marginPositive)Sets the positive margin that is enforced. | 
| protected void | setResult(DefaultKernelBinaryCategorizer<InputType> result)Sets the object currently being result. | 
| protected void | setSupportsMap(java.util.LinkedHashMap<InputOutputPair<? extends InputType,? extends java.lang.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. | 
clone, getData, getKeepGoing, learn, setData, setKeepGoing, stopgetMaxIterations, isResultValid, setMaxIterationsaddIterativeAlgorithmListener, fireAlgorithmEnded, fireAlgorithmStarted, fireStepEnded, fireStepStarted, getIteration, getListeners, removeIterativeAlgorithmListener, setIteration, setListenersequals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitlearnclonegetMaxIterations, setMaxIterationsaddIterativeAlgorithmListener, getIteration, removeIterativeAlgorithmListenerisResultValidpublic static final int DEFAULT_MAX_ITERATIONS
public static final double DEFAULT_MARGIN_POSITIVE
public static final double DEFAULT_MARGIN_NEGATIVE
public KernelPerceptron()
public KernelPerceptron(Kernel<? super InputType> kernel)
kernel - The kernel to use.public KernelPerceptron(Kernel<? super InputType> kernel, int maxIterations)
kernel - The kernel to use.maxIterations - The maximum number of iterations.public KernelPerceptron(Kernel<? super InputType> kernel, int maxIterations, double marginPositive, double marginNegative)
kernel - The kernel to use.maxIterations - The maximum number of iterations.marginPositive - The positive margin to enforce.marginNegative - The negative margin to enforce.protected boolean initializeAlgorithm()
AbstractAnytimeBatchLearnerinitializeAlgorithm in class AbstractAnytimeBatchLearner<java.util.Collection<? extends InputOutputPair<? extends InputType,java.lang.Boolean>>,DefaultKernelBinaryCategorizer<InputType>>protected boolean step()
AbstractAnytimeBatchLearnerstep in class AbstractAnytimeBatchLearner<java.util.Collection<? extends InputOutputPair<? extends InputType,java.lang.Boolean>>,DefaultKernelBinaryCategorizer<InputType>>protected void cleanupAlgorithm()
AbstractAnytimeBatchLearnercleanupAlgorithm in class AbstractAnytimeBatchLearner<java.util.Collection<? extends InputOutputPair<? extends InputType,java.lang.Boolean>>,DefaultKernelBinaryCategorizer<InputType>>public Kernel<? super InputType> getKernel()
public void setKernel(Kernel<? super InputType> kernel)
kernel - The kernel to use.public void setMargin(double margin)
margin - The new value for both the positive and negative margins.public double getMarginPositive()
public void setMarginPositive(double marginPositive)
marginPositive - The positive margin that is enforced.public double getMarginNegative()
public void setMarginNegative(double marginNegative)
marginNegative - The negative margin that is enforced.public DefaultKernelBinaryCategorizer<InputType> getResult()
AnytimeAlgorithmgetResult in interface AnytimeAlgorithm<DefaultKernelBinaryCategorizer<InputType>>protected void setResult(DefaultKernelBinaryCategorizer<InputType> result)
result - The object currently being result.public int getErrorCount()
protected void setErrorCount(int errorCount)
errorCount - The current error count.protected java.util.LinkedHashMap<InputOutputPair<? extends InputType,? extends java.lang.Boolean>,DefaultWeightedValue<InputType>> getSupportsMap()
protected void setSupportsMap(java.util.LinkedHashMap<InputOutputPair<? extends InputType,? extends java.lang.Boolean>,DefaultWeightedValue<InputType>> supportsMap)
supportsMap - The mapping of examples to weight objects.public NamedValue<java.lang.Integer> getPerformance()
MeasurablePerformanceAlgorithmgetPerformance in interface MeasurablePerformanceAlgorithm