JavaML
Class OnlineAdaBoost

java.lang.Object
  extended by JavaML.OnlineAdaBoost
All Implemented Interfaces:
IClassifier, IOnlineClassifier

public class OnlineAdaBoost
extends java.lang.Object
implements IOnlineClassifier

An implementation of Online Boosting. When using offline datasets, performs exactly like AdaBoost Can be primed by training on a small subset of data like AdaBoost and then commencing online learning updates. Executing the train() function resets the classifier before training


Field Summary
 
Fields inherited from interface JavaML.IClassifier
negativeClass, positiveClass
 
Constructor Summary
OnlineAdaBoost()
          Constructor, needs to be supplied with a weak learner before training
OnlineAdaBoost(int numLearners, IOnlineClassifier rootLearner, int learnerIterations, java.lang.String learnerArgs, boolean priming)
          Constructor, initialises everything required
OnlineAdaBoost(int numLearners, IOnlineClassifier rootLearner, java.lang.String learnerArgs, boolean priming)
          Constructor, initialises everything required
 
Method Summary
 int[] classifyDataset(IDataset testingData)
          Returns the classifications made by the trained classifier on the testing data
 int classifySample(double[] sample)
          Returns the classification for a single example
 IOnlineClassifier copyClassifier()
          Copy constructor
 int[] getFeatureList()
          Returns the list of features used by each weak learner (useful for decision stumps)
 boolean getIsTrained()
           
 int onlineTrain(double[] trainingData, int target)
          Is the online train function, which takes a single example and trains on it then returns the classification.
 void setRandomSeed(long newSeed)
           
 void setupClassifier(java.lang.String arguments)
          setupClassifier is used to modify classifiers after they have been constructed through the copy constructor, at that point you could either do reflection to figure out the class and reconstruct it, or you could pass it a string of arguments and have it reconfigure itself.
 boolean supportsMultiClassData()
           
 boolean supportsWeightedData()
           
 double test(IDataset testingData)
          Is the main offline test function, which takes an dataset and returns the testing error on that dataset
 double train(IDataset trainingData, int iterations)
          Is the main offline train function, which takes an dataset and trains on it using offline AdaBoost
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OnlineAdaBoost

public OnlineAdaBoost()
Constructor, needs to be supplied with a weak learner before training


OnlineAdaBoost

public OnlineAdaBoost(int numLearners,
                      IOnlineClassifier rootLearner,
                      java.lang.String learnerArgs,
                      boolean priming)
Constructor, initialises everything required

Parameters:
numLearners - Is the number of weak learners to use
rootLearner - Is an IOnlineClassifier which all the weak learners are constructed from
learnerArgs - Are any arguments that weak learner needs to be constructed with
priming - Specifies if the classifier is going to be trained offline first

OnlineAdaBoost

public OnlineAdaBoost(int numLearners,
                      IOnlineClassifier rootLearner,
                      int learnerIterations,
                      java.lang.String learnerArgs,
                      boolean priming)
Constructor, initialises everything required

Parameters:
numLearners - Is the number of weak learners to use
rootLearner - Is an IOnlineClassifier which all the weak learners are constructed from
learnerArgs - Are any arguments that weak learner needs to be constructed with
learnerIterations - If the weak learner needs the iterations parameter (e.g. for boosting a neural net)
priming - Specifies if the classifier is going to be trained offline first
Method Detail

copyClassifier

public IOnlineClassifier copyClassifier()
Copy constructor

Specified by:
copyClassifier in interface IClassifier
Specified by:
copyClassifier in interface IOnlineClassifier

setupClassifier

public void setupClassifier(java.lang.String arguments)
setupClassifier is used to modify classifiers after they have been constructed through the copy constructor, at that point you could either do reflection to figure out the class and reconstruct it, or you could pass it a string of arguments and have it reconfigure itself. This classifier accepts "WeakLearner= NumLearners= WeakLearnerIterations="

Specified by:
setupClassifier in interface IClassifier
Parameters:
arguments - a space separated list of parameter=value tuples.

train

public double train(IDataset trainingData,
                    int iterations)
Is the main offline train function, which takes an dataset and trains on it using offline AdaBoost

Specified by:
train in interface IClassifier
Parameters:
trainingData - A training dataset
iterations - overrides the inbuilt number of weak leaners, and creates iterations weak learners

onlineTrain

public int onlineTrain(double[] trainingData,
                       int target)
Is the online train function, which takes a single example and trains on it then returns the classification.

Specified by:
onlineTrain in interface IOnlineClassifier
Parameters:
trainingData - A training sample
target - class label for the sample

test

public double test(IDataset testingData)
Is the main offline test function, which takes an dataset and returns the testing error on that dataset

Specified by:
test in interface IClassifier
Parameters:
testingData - A testing dataset

classifyDataset

public int[] classifyDataset(IDataset testingData)
Returns the classifications made by the trained classifier on the testing data

Specified by:
classifyDataset in interface IClassifier
Parameters:
testingData - A testing dataset

classifySample

public int classifySample(double[] sample)
Returns the classification for a single example

Specified by:
classifySample in interface IClassifier
Parameters:
sample - A testing sample

setRandomSeed

public void setRandomSeed(long newSeed)

getFeatureList

public int[] getFeatureList()
Returns the list of features used by each weak learner (useful for decision stumps)

Specified by:
getFeatureList in interface IClassifier

getIsTrained

public boolean getIsTrained()
Specified by:
getIsTrained in interface IClassifier

supportsWeightedData

public boolean supportsWeightedData()
Specified by:
supportsWeightedData in interface IClassifier

supportsMultiClassData

public boolean supportsMultiClassData()
Specified by:
supportsMultiClassData in interface IClassifier