Package moa.classifiers.meta
Class AccuracyUpdatedEnsemble
- java.lang.Object
-
- moa.AbstractMOAObject
-
- moa.options.AbstractOptionHandler
-
- moa.classifiers.AbstractClassifier
-
- moa.classifiers.meta.AccuracyUpdatedEnsemble
-
- All Implemented Interfaces:
Configurable
,Serializable
,CapabilitiesHandler
,Classifier
,MultiClassClassifier
,AWTRenderable
,Learner<Example<Instance>>
,MOAObject
,OptionHandler
public class AccuracyUpdatedEnsemble extends AbstractClassifier implements MultiClassClassifier
The revised version of the Accuracy Updated Ensemble as proposed by Brzezinski and Stefanowski in "Reacting to Different Types of Concept Drift: The Accuracy Updated Ensemble Algorithm", IEEE Trans. Neural Netw, 2013.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected Classifier
candidate
Candidate classifier.IntOption
chunkSizeOption
Chunk size.protected long[]
classDistributions
Class distributions.protected Instances
currentChunk
Current chunk of instances.ClassOption
learnerOption
Type of classifier to use as a component classifier.protected Classifier[]
learners
Ensemble classifiers.IntOption
maxByteSizeOption
Determines the maximum size of model (evaluated after every chunk).IntOption
memberCountOption
Number of component classifiers.protected int
processedInstances
Number of processed examples.protected double[][]
weights
The weights of stored classifiers.-
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 AccuracyUpdatedEnsemble()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Classifier
addToStored(Classifier newClassifier, double newClassifiersWeight)
Adds a classifier to the storage.protected double
computeMse(Classifier learner, Instances chunk)
Computes the MSE of a learner for a given chunk of examples.protected double
computeMseR()
Computes the MSEr threshold.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.protected void
processChunk()
Processes a chunk of instances.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.
-
chunkSizeOption
public IntOption chunkSizeOption
Chunk size.
-
maxByteSizeOption
public IntOption maxByteSizeOption
Determines the maximum size of model (evaluated after every chunk). In effect only for HoeffdingTree-based component classifiers.
-
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.
-
learners
protected Classifier[] learners
Ensemble classifiers.
-
processedInstances
protected int processedInstances
Number of processed examples.
-
candidate
protected Classifier candidate
Candidate classifier.
-
currentChunk
protected Instances currentChunk
Current chunk of instances.
-
-
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
-
processChunk
protected void processChunk()
Processes a chunk of instances. This method is called after collecting a chunk of examples.
-
enforceMemoryLimit
protected void enforceMemoryLimit()
Checks if the memory limit is exceeded and if so prunes the classifiers in the ensemble.
-
computeMseR
protected double computeMseR()
Computes the MSEr threshold.- Returns:
- The MSEr threshold.
-
computeMse
protected double computeMse(Classifier learner, Instances chunk)
Computes the MSE of a learner for a given chunk of examples.- Parameters:
learner
- classifier to compute errorchunk
- chunk of examples- Returns:
- the computed error.
-
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 Classifier addToStored(Classifier newClassifier, double newClassifiersWeight)
Adds a classifier to the storage.- Parameters:
newClassifier
- The classifier to add.newClassifiersWeight
- The new classifiers weight.
-
-