Package moa.classifiers.meta
Class OnlineAccuracyUpdatedEnsemble
- java.lang.Object
-
- moa.AbstractMOAObject
-
- moa.options.AbstractOptionHandler
-
- moa.classifiers.AbstractClassifier
-
- moa.classifiers.meta.OnlineAccuracyUpdatedEnsemble
-
- All Implemented Interfaces:
Configurable
,Serializable
,CapabilitiesHandler
,Classifier
,MultiClassClassifier
,AWTRenderable
,Learner<Example<Instance>>
,MOAObject
,OptionHandler
public class OnlineAccuracyUpdatedEnsemble extends AbstractClassifier implements MultiClassClassifier
The online version of the Accuracy Updated Ensemble as proposed by Brzezinski and Stefanowski in "Combining block-based and online methods in learning ensembles from concept drifting data streams", Information Sciences, 2014.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
OnlineAccuracyUpdatedEnsemble.ClassifierWithMemory
-
Field Summary
Fields Modifier and Type Field Description protected OnlineAccuracyUpdatedEnsemble.ClassifierWithMemory
candidate
Candidate classifier.protected long[]
classDistributions
Class distributions.protected int[]
currentWindow
Current window of instance class values.protected OnlineAccuracyUpdatedEnsemble.ClassifierWithMemory[]
ensemble
Ensemble classifiers.ClassOption
learnerOption
Type of classifier to use as a component classifier.FlagOption
linearOption
Determines whether additional information should be sent to the output.IntOption
maxByteSizeOption
Determines the maximum size of model (evaluated after every chunk).IntOption
memberCountOption
Number of component classifiers.protected double
mse_r
The mean square residual in a given moment, based on a window of latest examples.protected int
processedInstances
Number of processed examples.FlagOption
verboseOption
Determines whether additional information should be sent to the output.protected double[][]
weights
The weights of stored classifiers.protected int
windowSize
Window size.FloatOption
windowSizeOption
Chunk size.-
Fields inherited from class moa.classifiers.AbstractClassifier
classifierRandom, modelContext, randomSeed, randomSeedOption, trainingWeightSeenByModel
-
Fields inherited from class moa.options.AbstractOptionHandler
config
-
-
Constructor Summary
Constructors Constructor Description OnlineAccuracyUpdatedEnsemble()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addToStored(OnlineAccuracyUpdatedEnsemble.ClassifierWithMemory newClassifier, double newClassifiersWeight)
Adds a classifier to the storage.protected void
computeMseR()
Computes the MSEr threshold.protected double
computeWeight(int i, Instance example)
Computes the weight of a learner before training a given example.protected void
createNewClassifier(Instance inst)
Processes a chunk.protected void
enforceMemoryLimit()
Checks if the memory limit is exceeded and if so prunes the classifiers in the ensemble.void
getModelDescription(StringBuilder out, int indent)
Returns a string representation of the model.protected Measurement[]
getModelMeasurementsImpl()
Adds ensemble weights to the measurements.Classifier[]
getSubClassifiers()
Gets the classifiers of this ensemble.double[]
getVotesForInstance(Instance inst)
Predicts a class for an example.boolean
isRandomizable()
Determines whether the classifier is randomizable.void
prepareForUseImpl(TaskMonitor monitor, ObjectRepository repository)
This method describes the implementation of how to prepare this object for use.void
resetLearningImpl()
Resets this classifier.void
trainOnInstanceImpl(Instance inst)
Trains this classifier incrementally using the given instance.
The reason for ...Impl methods: ease programmer burden by not requiring them to remember calls to super in overridden methods.-
Methods inherited from class moa.classifiers.AbstractClassifier
contextIsCompatible, copy, correctlyClassifies, defineImmutableCapabilities, getAttributeNameString, getAWTRenderer, getClassLabelString, getClassNameString, getDescription, getModel, getModelContext, getModelMeasurements, getNominalValueString, getPredictionForInstance, getPredictionForInstance, getPurposeString, getSublearners, getVotesForInstance, modelAttIndexToInstanceAttIndex, modelAttIndexToInstanceAttIndex, resetLearning, setModelContext, setRandomSeed, trainingHasStarted, trainingWeightSeenByModel, trainOnInstance, trainOnInstance
-
Methods inherited from class moa.options.AbstractOptionHandler
getCLICreationString, getOptions, getPreparedClassOption, prepareClassOptions, prepareForUse, prepareForUse
-
Methods inherited from class moa.AbstractMOAObject
copy, measureByteSize, measureByteSize, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface moa.capabilities.CapabilitiesHandler
getCapabilities
-
Methods inherited from interface moa.MOAObject
measureByteSize
-
Methods inherited from interface moa.options.OptionHandler
getCLICreationString, getOptions, prepareForUse, prepareForUse
-
-
-
-
Field Detail
-
learnerOption
public ClassOption learnerOption
Type of classifier to use as a component classifier.
-
memberCountOption
public IntOption memberCountOption
Number of component classifiers.
-
windowSizeOption
public FloatOption windowSizeOption
Chunk size.
-
maxByteSizeOption
public IntOption maxByteSizeOption
Determines the maximum size of model (evaluated after every chunk).
-
verboseOption
public FlagOption verboseOption
Determines whether additional information should be sent to the output.
-
linearOption
public FlagOption linearOption
Determines whether additional information should be sent to the output.
-
weights
protected double[][] weights
The weights of stored classifiers. weights[x][0] = weight weights[x][1] = classifier number in learners
-
classDistributions
protected long[] classDistributions
Class distributions.
-
ensemble
protected OnlineAccuracyUpdatedEnsemble.ClassifierWithMemory[] ensemble
Ensemble classifiers.
-
processedInstances
protected int processedInstances
Number of processed examples.
-
candidate
protected OnlineAccuracyUpdatedEnsemble.ClassifierWithMemory candidate
Candidate classifier.
-
currentWindow
protected int[] currentWindow
Current window of instance class values.
-
mse_r
protected double mse_r
The mean square residual in a given moment, based on a window of latest examples.
-
windowSize
protected int windowSize
Window size.
-
-
Method Detail
-
prepareForUseImpl
public void prepareForUseImpl(TaskMonitor monitor, ObjectRepository repository)
Description copied from class:AbstractOptionHandler
This method describes the implementation of how to prepare this object for use. All classes that extends this class have to implementprepareForUseImpl
and notprepareForUse
sinceprepareForUse
callsprepareForUseImpl
.- Overrides:
prepareForUseImpl
in classAbstractClassifier
- Parameters:
monitor
- the TaskMonitor to userepository
- the ObjectRepository to use
-
resetLearningImpl
public void resetLearningImpl()
Description copied from class:AbstractClassifier
Resets this classifier. It must be similar to starting a new classifier from scratch.
The reason for ...Impl methods: ease programmer burden by not requiring them to remember calls to super in overridden methods. Note that this will produce compiler errors if not overridden.- Specified by:
resetLearningImpl
in classAbstractClassifier
-
trainOnInstanceImpl
public void trainOnInstanceImpl(Instance inst)
Description copied from class:AbstractClassifier
Trains this classifier incrementally using the given instance.
The reason for ...Impl methods: ease programmer burden by not requiring them to remember calls to super in overridden methods. Note that this will produce compiler errors if not overridden.- Specified by:
trainOnInstanceImpl
in classAbstractClassifier
- Parameters:
inst
- the instance to be used for training
-
isRandomizable
public boolean isRandomizable()
Determines whether the classifier is randomizable.- Specified by:
isRandomizable
in interfaceLearner<Example<Instance>>
- Returns:
- true if the learner needs a random seed.
-
getVotesForInstance
public double[] getVotesForInstance(Instance inst)
Predicts a class for an example.- Specified by:
getVotesForInstance
in interfaceClassifier
- Specified by:
getVotesForInstance
in classAbstractClassifier
- Parameters:
inst
- the instance to be classified- Returns:
- an array containing the estimated membership probabilities of the test instance in each class
-
getModelDescription
public void getModelDescription(StringBuilder out, int indent)
Description copied from class:AbstractClassifier
Returns a string representation of the model.- Specified by:
getModelDescription
in classAbstractClassifier
- Parameters:
out
- the stringbuilder to add the descriptionindent
- the number of characters to indent
-
getSubClassifiers
public Classifier[] getSubClassifiers()
Description copied from interface:Classifier
Gets the classifiers of this ensemble. Returns null if this learner is a single learner.- Specified by:
getSubClassifiers
in interfaceClassifier
- Overrides:
getSubClassifiers
in classAbstractClassifier
- Returns:
- an array of the learners of the ensemble
-
createNewClassifier
protected void createNewClassifier(Instance inst)
Processes a chunk.- Parameters:
inst
- New example
-
enforceMemoryLimit
protected void enforceMemoryLimit()
Checks if the memory limit is exceeded and if so prunes the classifiers in the ensemble.
-
computeMseR
protected void computeMseR()
Computes the MSEr threshold.
-
computeWeight
protected double computeWeight(int i, Instance example)
Computes the weight of a learner before training a given example.- Parameters:
i
- the identifier (in terms of array learners) of the classifier for which the weight is supposed to be computedexample
- the newest example- Returns:
- the computed weight.
-
getModelMeasurementsImpl
protected Measurement[] getModelMeasurementsImpl()
Adds ensemble weights to the measurements.- Specified by:
getModelMeasurementsImpl
in classAbstractClassifier
- Returns:
- an array of measurements to be used in evaluation tasks
-
addToStored
protected void addToStored(OnlineAccuracyUpdatedEnsemble.ClassifierWithMemory newClassifier, double newClassifiersWeight)
Adds a classifier to the storage.- Parameters:
newClassifier
- The classifier to add.newClassifiersWeight
- The new classifiers weight.
-
-