public class KernelBinaryOnlineAlgorithm<E>
extends java.lang.Object
implements java.io.Serializable
The objective of this class is to train or retrain an OnlineEngine using a set of data instances. It iteratively calls the updateModel method until the number of iterations reach a number specified by variable numEpochs over the list of data samples
Constructor and Description |
---|
KernelBinaryOnlineAlgorithm(java.util.List<DataObject<E>> trainingData,
java.util.Map<java.lang.Integer,java.lang.Boolean> labels,
int currentEpoch,
int numEpochs,
OnlineEngine<E> engine,
boolean cacheMatrix,
java.util.List<EngineObserver<E>> observers,
java.lang.String classifier)
Calls the training for the OnlineEngine
|
KernelBinaryOnlineAlgorithm(java.util.List<DataObject<E>> trainingData,
java.util.Map<java.lang.Integer,java.lang.Boolean> labels,
int numEpochs,
OnlineEngine<E> engine,
boolean cacheMatrix,
java.util.List<EngineObserver<E>> observers,
java.lang.String classifier)
Calls the training for the OnlineEngine
|
Modifier and Type | Method and Description |
---|---|
void |
addExampleAndUpdate(DataObject<E> inputVector,
boolean desiredOutput)
Trains the OnlineEngine with a data sample
|
boolean |
classify(DataObject<E> vector)
Assigns a binary label to a data sample
|
double |
getB()
Gets the bias term value present at SVM based OnlineEngine
|
java.util.Map<DataObject<E>,java.lang.Double> |
getWeights()
Used for SVM based OnlineEngine, it returns the weights for the Support
Vectors
|
public KernelBinaryOnlineAlgorithm(java.util.List<DataObject<E>> trainingData, java.util.Map<java.lang.Integer,java.lang.Boolean> labels, int currentEpoch, int numEpochs, OnlineEngine<E> engine, boolean cacheMatrix, java.util.List<EngineObserver<E>> observers, java.lang.String classifier) throws InvalidVectorIndexException
trainingData
- the list of data samples used for traininglabels
- a Map containing the data samples as keys and their labels as
valuescurrentEpoch
- the initial iteration of the algorithm,
used mainly to continue a already trained OnlineEnginenumEpochs
- the number of iterations to go over the trainingDataengine
- the OnlineEngine to be trainedcacheMatrix
- boolean to request a pre-computed matrix in kernel based
OnlineLearningobservers
- A list of EngineObservers that will obtain information
during the trainingclassifier
- the name of the classifier, used mainly to distinguish
binary engines in multi-class problemsInvalidVectorIndexException
- when a DataObject from the data
instances to be transforms has occupied reserved space for
constantspublic KernelBinaryOnlineAlgorithm(java.util.List<DataObject<E>> trainingData, java.util.Map<java.lang.Integer,java.lang.Boolean> labels, int numEpochs, OnlineEngine<E> engine, boolean cacheMatrix, java.util.List<EngineObserver<E>> observers, java.lang.String classifier) throws InvalidVectorIndexException
trainingData
- the list of data samples used for traininglabels
- a Map containing the data samples as keys and their labels as
valuesnumEpochs
- the number of iterations to go over the trainingDataengine
- the OnlineEngine to be trainedcacheMatrix
- boolean to request a pre-computed matrix in kernel based
OnlineLearningobservers
- A list of EngineObservers that will obtain information
during the trainingclassifier
- the name of the classifier, used mainly to distinguish
binary engines in multi-class problemsInvalidVectorIndexException
- when a DataObject from the data
instances to be transforms has occupied reserved space for
constantspublic boolean classify(DataObject<E> vector) throws InvalidVectorIndexException
vector
- the data sampleInvalidVectorIndexException
- indicates that the DataObject that
this method tried to convert contains a reserved space for a constant
that it is occupiedpublic void addExampleAndUpdate(DataObject<E> inputVector, boolean desiredOutput) throws InvalidVectorIndexException
inputVector
- the data sampledesiredOutput
- the binary labelInvalidVectorIndexException
- indicates that the DataObject that
this method tried to convert contains a reserved space for a constant
that it is occupiedpublic java.util.Map<DataObject<E>,java.lang.Double> getWeights()
public double getB()