InputType
- Input parameter to the Kernels@PublicationReference(author={"John Shawe-Taylor","Nello Cristianini"}, title="Kernel Methods for Pattern Analysis", type=Book, year=2004, url="http://www.kernel-methods.net/") public class KernelBasedIterativeRegression<InputType> extends AbstractAnytimeSupervisedBatchLearner<InputType,java.lang.Double,KernelScalarFunction<InputType>> implements MeasurablePerformanceAlgorithm
KernelBasedIterativeRegression
class implements an online version of
the Support Vector Regression algorithm. It learns a scalar kernel function
that uses the given kernel to map inputs onto real numbers. The code is based
on the pseudocode in the book "Kernel Methods for Pattern Analysis" by
J. Shawe-Taylor and N. Cristianini. However, this the pseudo-code in the
book is incorrect and seems to be missing an extra division by the kernel
of the example with itself. It also does not check to make sure that the
error is outside of the minimum sensitivity range. This implementation also
includes a bias term, which is also omitted from the pseudo-code in the book.
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_MAX_ITERATIONS
The default maximum number of iterations, 100.
|
static double |
DEFAULT_MIN_SENSITIVITY
The default minimum sensitivity, 10.0.
|
data, keepGoing
maxIterations
DEFAULT_ITERATION, iteration
Constructor and Description |
---|
KernelBasedIterativeRegression()
Creates a new instance of KernelBasedIterativeRegression.
|
KernelBasedIterativeRegression(Kernel<? super InputType> kernel)
Creates a new KernelBasedIterativeRegression with the given kernel.
|
KernelBasedIterativeRegression(Kernel<? super InputType> kernel,
double minSensitivity)
Creates a new KernelBasedIterativeRegression with the given kernel.
|
KernelBasedIterativeRegression(Kernel<? super InputType> kernel,
double minSensitivity,
int maxIterations)
Creates a new KernelBasedIterativeRegression with the given kernel and
maximum number of iterations.
|
Modifier and Type | Method and Description |
---|---|
protected void |
cleanupAlgorithm()
Called to clean up the learning algorithm's state after learning has
finished.
|
KernelBasedIterativeRegression<InputType> |
clone()
This makes public the clone method on the
Object class and
removes the exception that it throws. |
int |
getErrorCount()
Gets the error count of the most recent iteration.
|
Kernel<? super InputType> |
getKernel()
Gets the kernel to use.
|
double |
getMinSensitivity()
Gets the minimum sensitivity that an example can have on the result
function.
|
NamedValue<java.lang.Integer> |
getPerformance()
Gets the performance, which is the error count on the last iteration.
|
KernelScalarFunction<InputType> |
getResult()
Gets the current result of the algorithm.
|
protected java.util.LinkedHashMap<InputOutputPair<? extends InputType,java.lang.Double>,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 |
setMinSensitivity(double minSensitivity)
Sets the minimum sensitivity that an example can have on the result
function.
|
protected void |
setResult(KernelScalarFunction<InputType> result)
Sets the object currently being result.
|
protected void |
setSupportsMap(java.util.LinkedHashMap<InputOutputPair<? extends InputType,java.lang.Double>,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.
|
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
learn
getMaxIterations, setMaxIterations
addIterativeAlgorithmListener, getIteration, removeIterativeAlgorithmListener
isResultValid
public static final int DEFAULT_MAX_ITERATIONS
public static final double DEFAULT_MIN_SENSITIVITY
public KernelBasedIterativeRegression()
public KernelBasedIterativeRegression(Kernel<? super InputType> kernel)
kernel
- The kernel to use.public KernelBasedIterativeRegression(Kernel<? super InputType> kernel, double minSensitivity)
kernel
- The kernel to use.minSensitivity
- The minimum sensitivity to errors.public KernelBasedIterativeRegression(Kernel<? super InputType> kernel, double minSensitivity, int maxIterations)
kernel
- The kernel to use.minSensitivity
- The minimum sensitivity to errors.maxIterations
- The maximum number of iterations.public KernelBasedIterativeRegression<InputType> clone()
AbstractCloneableSerializable
Object
class and
removes the exception that it throws. Its default behavior is to
automatically create a clone of the exact type of object that the
clone is called on and to copy all primitives but to keep all references,
which means it is a shallow copy.
Extensions of this class may want to override this method (but call
super.clone()
to implement a "smart copy". That is, to target
the most common use case for creating a copy of the object. Because of
the default behavior being a shallow copy, extending classes only need
to handle fields that need to have a deeper copy (or those that need to
be reset). Some of the methods in ObjectUtil
may be helpful in
implementing a custom clone method.
Note: The contract of this method is that you must use
super.clone()
as the basis for your implementation.clone
in interface CloneableSerializable
clone
in class AbstractAnytimeBatchLearner<java.util.Collection<? extends InputOutputPair<? extends InputType,java.lang.Double>>,KernelScalarFunction<InputType>>
protected boolean initializeAlgorithm()
AbstractAnytimeBatchLearner
initializeAlgorithm
in class AbstractAnytimeBatchLearner<java.util.Collection<? extends InputOutputPair<? extends InputType,java.lang.Double>>,KernelScalarFunction<InputType>>
protected boolean step()
AbstractAnytimeBatchLearner
step
in class AbstractAnytimeBatchLearner<java.util.Collection<? extends InputOutputPair<? extends InputType,java.lang.Double>>,KernelScalarFunction<InputType>>
protected void cleanupAlgorithm()
AbstractAnytimeBatchLearner
cleanupAlgorithm
in class AbstractAnytimeBatchLearner<java.util.Collection<? extends InputOutputPair<? extends InputType,java.lang.Double>>,KernelScalarFunction<InputType>>
public Kernel<? super InputType> getKernel()
public void setKernel(Kernel<? super InputType> kernel)
kernel
- The kernel to use.public KernelScalarFunction<InputType> getResult()
AnytimeAlgorithm
getResult
in interface AnytimeAlgorithm<KernelScalarFunction<InputType>>
protected void setResult(KernelScalarFunction<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,java.lang.Double>,DefaultWeightedValue<InputType>> getSupportsMap()
protected void setSupportsMap(java.util.LinkedHashMap<InputOutputPair<? extends InputType,java.lang.Double>,DefaultWeightedValue<InputType>> supportsMap)
supportsMap
- The mapping of examples to weight objects.public double getMinSensitivity()
public void setMinSensitivity(double minSensitivity)
minSensitivity
- The minimum sensitivity.public NamedValue<java.lang.Integer> getPerformance()
getPerformance
in interface MeasurablePerformanceAlgorithm