InputType - The type of the input data.@CodeReview(reviewer="Kevin R. Dixon", date="2008-07-23", changesNeeded=false, comments={"Minor cosmetic to javadoc.","Great looking code."}) @PublicationReference(author={"Olvi L. Mangasarian","David R. Musicant"}, title="Successive Overrelaxation for Support Vector Machines", type=Journal, year=1999, publication="IEEE Transactions on Neural Networks", pages={1032,1037}, url="ftp://ftp.cs.wisc.edu/math-prog/tech-reports/98-18.ps") public class SuccessiveOverrelaxation<InputType> extends AbstractAnytimeSupervisedBatchLearner<InputType,java.lang.Boolean,KernelBinaryCategorizer<InputType,DefaultWeightedValue<InputType>>> implements MeasurablePerformanceAlgorithm
SuccessiveOverrelaxation class implements the Successive
Overrelaxation (SOR) algorithm for learning a Support Vector Machine (SVM).| Modifier and Type | Class and Description |
|---|---|
protected class |
SuccessiveOverrelaxation.Entry
The
Entry class represents the data that the algorithm keeps
about each training example. |
| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_MAX_ITERATIONS
The default maximum number of iterations, 1000.
|
static double |
DEFAULT_MAX_WEIGHT
The default maximum weight is 100.0.
|
static double |
DEFAULT_MIN_CHANGE
The default minimum change is 1.0E-4.
|
static double |
DEFAULT_OVERRELAXATION
The default overrelaxation is 1.3.
|
protected java.util.ArrayList<SuccessiveOverrelaxation.Entry> |
entries
The entry information that the algorithm keeps.
|
protected Kernel<? super InputType> |
kernel
The kernel to use.
|
protected double |
maxWeight
The maximum weight for a support vector.
|
protected double |
minChange
The minimum change to allow for the algorithm to keep going.
|
protected double |
overrelaxation
The overrelaxation parameter.
|
protected KernelBinaryCategorizer<InputType,DefaultWeightedValue<InputType>> |
result
The result categorizer.
|
protected java.util.LinkedHashMap<InputOutputPair<? extends InputType,? extends java.lang.Boolean>,SuccessiveOverrelaxation.Entry> |
supportsMap
The mapping of weight objects to non-zero weighted examples
(support vectors).
|
protected double |
totalChange
The total change on the most recent pass.
|
data, keepGoingmaxIterationsDEFAULT_ITERATION, iteration| Constructor and Description |
|---|
SuccessiveOverrelaxation()
Creates a new instance of
SuccessiveOverrelaxation. |
SuccessiveOverrelaxation(Kernel<? super InputType> kernel)
Creates a new instance of
SuccessiveOverrelaxation. |
SuccessiveOverrelaxation(Kernel<? super InputType> kernel,
double maxWeight,
double overrelaxation,
double minChange,
int maxIterations)
Creates a new instance of
SuccessiveOverrelaxation. |
| Modifier and Type | Method and Description |
|---|---|
protected void |
cleanupAlgorithm()
Called to clean up the learning algorithm's state after learning has
finished.
|
protected java.util.ArrayList<SuccessiveOverrelaxation.Entry> |
getEntries()
Gets the data that the algorithm keeps for each training instance.
|
Kernel<? super InputType> |
getKernel()
Gets the kernel to use.
|
double |
getMaxWeight()
Gets the maximum weight allowed on an instance (support vector).
|
double |
getMinChange()
Gets the minimum total weight change allowed for the algorithm to
continue.
|
double |
getOverrelaxation()
Gets the overrelaxation parameter for the algorithm.
|
NamedValue<java.lang.Double> |
getPerformance()
Gets the performance, which is the total change on the last iteration.
|
KernelBinaryCategorizer<InputType,DefaultWeightedValue<InputType>> |
getResult()
Gets the current result of the algorithm.
|
protected java.util.LinkedHashMap<InputOutputPair<? extends InputType,? extends java.lang.Boolean>,SuccessiveOverrelaxation.Entry> |
getSupportsMap()
Gets the mapping of examples to weight objects (support vectors).
|
double |
getTotalChange()
Gets the total change in weight from the most recent step of the
algorithm.
|
protected boolean |
initializeAlgorithm()
Called to initialize the learning algorithm's state based on the
data that is stored in the data field.
|
protected void |
setEntries(java.util.ArrayList<SuccessiveOverrelaxation.Entry> entries)
Gets the data that the algorithm keeps for each training instance.
|
void |
setKernel(Kernel<? super InputType> kernel)
Sets the kernel to use.
|
void |
setMaxWeight(double maxWeight)
Sets the maximum weight allowed on an instance (support vector).
|
void |
setMinChange(double minChange)
Sets the minimum total weight change allowed for the algorithm to
continue.
|
void |
setOverrelaxation(double overrelaxation)
Gets the overrelaxation parameter for the algorithm.
|
protected void |
setResult(KernelBinaryCategorizer<InputType,DefaultWeightedValue<InputType>> result)
Sets the object currently being result.
|
protected void |
setSupportsMap(java.util.LinkedHashMap<InputOutputPair<? extends InputType,? extends java.lang.Boolean>,SuccessiveOverrelaxation.Entry> supportsMap)
Gets the mapping of examples to weight objects (support vectors).
|
protected void |
setTotalChange(double totalChange)
Gets the total change in weight from the most recent step of the
algorithm.
|
protected boolean |
step()
Called to take a single step of the learning algorithm.
|
protected void |
update(SuccessiveOverrelaxation.Entry entry)
Performs an update step on the given entry using the successive
overrelaxation procedure.
|
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_MAX_WEIGHT
public static final double DEFAULT_OVERRELAXATION
public static final double DEFAULT_MIN_CHANGE
protected double maxWeight
protected double overrelaxation
protected double minChange
protected KernelBinaryCategorizer<InputType,DefaultWeightedValue<InputType>> result
protected double totalChange
protected java.util.ArrayList<SuccessiveOverrelaxation.Entry> entries
protected java.util.LinkedHashMap<InputOutputPair<? extends InputType,? extends java.lang.Boolean>,SuccessiveOverrelaxation.Entry> supportsMap
public SuccessiveOverrelaxation()
SuccessiveOverrelaxation.public SuccessiveOverrelaxation(Kernel<? super InputType> kernel)
SuccessiveOverrelaxation.kernel - The kernel function to use.public SuccessiveOverrelaxation(Kernel<? super InputType> kernel, double maxWeight, double overrelaxation, double minChange, int maxIterations)
SuccessiveOverrelaxation.kernel - The kernel function to use.maxWeight - The maximum weight allowed for a support vector. Must be positive.overrelaxation - The overrelaxation parameter. Must be in (0, 2), exclusive.minChange - The minimum change to allow for the algorithm to continue. Must
be positive.maxIterations - The maximum number of iterations to run for.protected boolean initializeAlgorithm()
AbstractAnytimeBatchLearnerinitializeAlgorithm in class AbstractAnytimeBatchLearner<java.util.Collection<? extends InputOutputPair<? extends InputType,java.lang.Boolean>>,KernelBinaryCategorizer<InputType,DefaultWeightedValue<InputType>>>protected boolean step()
AbstractAnytimeBatchLearnerstep in class AbstractAnytimeBatchLearner<java.util.Collection<? extends InputOutputPair<? extends InputType,java.lang.Boolean>>,KernelBinaryCategorizer<InputType,DefaultWeightedValue<InputType>>>protected void update(SuccessiveOverrelaxation.Entry entry)
entry - The entry to update.protected void cleanupAlgorithm()
AbstractAnytimeBatchLearnercleanupAlgorithm in class AbstractAnytimeBatchLearner<java.util.Collection<? extends InputOutputPair<? extends InputType,java.lang.Boolean>>,KernelBinaryCategorizer<InputType,DefaultWeightedValue<InputType>>>public Kernel<? super InputType> getKernel()
public void setKernel(Kernel<? super InputType> kernel)
kernel - The kernel to use.public double getMaxWeight()
public void setMaxWeight(double maxWeight)
maxWeight - The maximum weight allowed on an instance.public double getOverrelaxation()
public void setOverrelaxation(double overrelaxation)
overrelaxation - The overrelaxation parameter for the algorithm.public double getMinChange()
public void setMinChange(double minChange)
minChange - The minimum total weight change allowed for the
algorithm to continue.public KernelBinaryCategorizer<InputType,DefaultWeightedValue<InputType>> getResult()
AnytimeAlgorithmgetResult in interface AnytimeAlgorithm<KernelBinaryCategorizer<InputType,DefaultWeightedValue<InputType>>>protected void setResult(KernelBinaryCategorizer<InputType,DefaultWeightedValue<InputType>> result)
result - The object currently being result.protected java.util.ArrayList<SuccessiveOverrelaxation.Entry> getEntries()
protected void setEntries(java.util.ArrayList<SuccessiveOverrelaxation.Entry> entries)
entries - The data kept for each training instance.protected java.util.LinkedHashMap<InputOutputPair<? extends InputType,? extends java.lang.Boolean>,SuccessiveOverrelaxation.Entry> getSupportsMap()
protected void setSupportsMap(java.util.LinkedHashMap<InputOutputPair<? extends InputType,? extends java.lang.Boolean>,SuccessiveOverrelaxation.Entry> supportsMap)
supportsMap - The mapping of examples to weight objects.public double getTotalChange()
protected void setTotalChange(double totalChange)
totalChange - The total change in weight from the most recent
step.public NamedValue<java.lang.Double> getPerformance()
getPerformance in interface MeasurablePerformanceAlgorithm