InputType
- The type of the input data to learn the support vector machine.@PublicationReference(title="Fast training of support vector machines using sequential minimal optimization", author="John C. Platt", year=1999, type=BookChapter, pages={185,208}, publication="Advances in Kernel Methods", url="http://research.microsoft.com/pubs/68391/smo-book.pdf") public class SequentialMinimalOptimization<InputType> extends AbstractAnytimeSupervisedBatchLearner<InputType,java.lang.Boolean,KernelBinaryCategorizer<InputType,DefaultWeightedValue<InputType>>> implements KernelContainer<InputType>, Randomized, MeasurablePerformanceAlgorithm
Modifier and Type | Field and Description |
---|---|
static double |
DEFAULT_EFFECTIVE_ZERO
The default effective value for zero is 1.0E-10.
|
static double |
DEFAULT_ERROR_TOLERANCE
The default error tolerance is 0.001, which is what was recommended in
the original Sequential Minimal Optimization paper.
|
static int |
DEFAULT_KERNEL_CACHE_SIZE
The default size of the kernel cache.
|
static int |
DEFAULT_MAX_ITERATIONS
The default maximum number of iterations is 1000.
|
static double |
DEFAULT_MAX_PENALTY
The default maximum penalty is infinite, which means that it is
hard-assignment.
|
static java.lang.String |
PERFORMANCE_NAME
The performance name is "Change count".
|
data, keepGoing
maxIterations
DEFAULT_ITERATION, iteration
Constructor and Description |
---|
SequentialMinimalOptimization()
Creates a new instance of Sequential Minimal Optimization.
|
SequentialMinimalOptimization(Kernel<? super InputType> kernel)
Creates a new instance of Sequential Minimal Optimization with the
given kernel.
|
SequentialMinimalOptimization(Kernel<? super InputType> kernel,
double maxPenalty,
double errorTolerance,
double effectiveZero,
int kernelCacheSize,
int maxIterations,
java.util.Random random)
Creates a new instance of Sequential Minimal Optimization with the
given kernel and random number generator.
|
SequentialMinimalOptimization(Kernel<? super InputType> kernel,
java.util.Random random)
Creates a new instance of Sequential Minimal Optimization with the
given kernel and random number generator.
|
Modifier and Type | Method and Description |
---|---|
protected void |
cleanupAlgorithm()
Called to clean up the learning algorithm's state after learning has
finished.
|
protected int |
examineExample(int j)
Examines one example in order to try and take a step of SMO using it.
|
int |
getChangeCount()
Gets the number of changes made on the last iteration of the algorithm.
|
double |
getEffectiveZero()
Gets the effective value for zero to use in the computation to deal with
numerical imprecision.
|
double |
getErrorTolerance()
Gets the error tolerance for the algorithm.
|
Kernel<? super InputType> |
getKernel()
Gets the kernel.
|
int |
getKernelCacheSize()
Gets the size of the kernel cache or 0 if no kernel cache is to be used.
|
double |
getMaxPenalty()
Gets the maximum penalty parameter for the algorithm, which is also known
as C in the paper and in other related literature.
|
DefaultNamedValue<java.lang.Integer> |
getPerformance()
Gets the name-value pair that describes the current performance of the
algorithm.
|
java.util.Random |
getRandom()
Gets the random number generator used by this object.
|
KernelBinaryCategorizer<InputType,DefaultWeightedValue<InputType>> |
getResult()
Gets the current result 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.
|
void |
setEffectiveZero(double effectiveZero)
Sets the effective value for zero to use in the computation to deal with
numerical imprecision.
|
void |
setErrorTolerance(double errorTolerance)
Sets the error tolerance for the algorithm.
|
void |
setKernel(Kernel<? super InputType> kernel)
Sets the kernel to use in training the SVM.
|
void |
setKernelCacheSize(int kernelCacheSize)
Sets the size of the kernel cache or 0 if no kernel cache is to be used.
|
void |
setMaxPenalty(double maxPenalty)
Sets the maximum penalty parameter for the algorithm, which is also known
as C in the paper and in other related literature.
|
void |
setRandom(java.util.Random random)
Sets the random number generator used by this object.
|
protected boolean |
step()
Called to take a single step of the learning algorithm.
|
clone, getData, getKeepGoing, learn, setData, setKeepGoing, stop
getMaxIterations, isResultValid, setMaxIterations
addIterativeAlgorithmListener, fireAlgorithmEnded, fireAlgorithmStarted, fireStepEnded, fireStepStarted, getIteration, getListeners, removeIterativeAlgorithmListener, setIteration, setListeners
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
clone
learn
getMaxIterations, setMaxIterations
addIterativeAlgorithmListener, getIteration, removeIterativeAlgorithmListener
isResultValid
public static final int DEFAULT_MAX_ITERATIONS
public static final double DEFAULT_MAX_PENALTY
public static final double DEFAULT_ERROR_TOLERANCE
public static final double DEFAULT_EFFECTIVE_ZERO
public static final int DEFAULT_KERNEL_CACHE_SIZE
public static final java.lang.String PERFORMANCE_NAME
public SequentialMinimalOptimization()
public SequentialMinimalOptimization(Kernel<? super InputType> kernel)
kernel
- The kernel to use.public SequentialMinimalOptimization(Kernel<? super InputType> kernel, java.util.Random random)
kernel
- The kernel to use.random
- The random number generator to use.public SequentialMinimalOptimization(Kernel<? super InputType> kernel, double maxPenalty, double errorTolerance, double effectiveZero, int kernelCacheSize, int maxIterations, java.util.Random random)
kernel
- The kernel to use.maxPenalty
- The maximum penalty parameter (C). Must be greater than 0.0.errorTolerance
- The error tolerance for the algorithm. Must be non-negative.effectiveZero
- The effective value for zero. Must be non-negative.kernelCacheSize
- The size of the kernel cache. Must be non-negative.maxIterations
- The maximum number of iterations to run the algorithm.random
- The random number generator to use.protected boolean initializeAlgorithm()
AbstractAnytimeBatchLearner
initializeAlgorithm
in class AbstractAnytimeBatchLearner<java.util.Collection<? extends InputOutputPair<? extends InputType,java.lang.Boolean>>,KernelBinaryCategorizer<InputType,DefaultWeightedValue<InputType>>>
protected boolean step()
AbstractAnytimeBatchLearner
step
in class AbstractAnytimeBatchLearner<java.util.Collection<? extends InputOutputPair<? extends InputType,java.lang.Boolean>>,KernelBinaryCategorizer<InputType,DefaultWeightedValue<InputType>>>
protected void cleanupAlgorithm()
AbstractAnytimeBatchLearner
cleanupAlgorithm
in class AbstractAnytimeBatchLearner<java.util.Collection<? extends InputOutputPair<? extends InputType,java.lang.Boolean>>,KernelBinaryCategorizer<InputType,DefaultWeightedValue<InputType>>>
protected int examineExample(int j)
j
- The index of the example to examine.public KernelBinaryCategorizer<InputType,DefaultWeightedValue<InputType>> getResult()
AnytimeAlgorithm
getResult
in interface AnytimeAlgorithm<KernelBinaryCategorizer<InputType,DefaultWeightedValue<InputType>>>
public Kernel<? super InputType> getKernel()
KernelContainer
getKernel
in interface KernelContainer<InputType>
public void setKernel(Kernel<? super InputType> kernel)
kernel
- The kernel to use in training the SVM.public double getMaxPenalty()
public void setMaxPenalty(double maxPenalty)
maxPenalty
- The maximum penalty parameter (C). Must be greater than 0.0.public double getErrorTolerance()
public void setErrorTolerance(double errorTolerance)
errorTolerance
- The error tolerance for the algorithm. Must be non-negative.public double getEffectiveZero()
public void setEffectiveZero(double effectiveZero)
effectiveZero
- The effective value for zero. Must be non-negative.public int getKernelCacheSize()
public void setKernelCacheSize(int kernelCacheSize)
kernelCacheSize
- The size of the kernel cache. Must be non-negative.public java.util.Random getRandom()
Randomized
getRandom
in interface Randomized
public void setRandom(java.util.Random random)
Randomized
setRandom
in interface Randomized
random
- The random number generator for this object to use.public int getChangeCount()
public DefaultNamedValue<java.lang.Integer> getPerformance()
MeasurablePerformanceAlgorithm
getPerformance
in interface MeasurablePerformanceAlgorithm