Package moa.classifiers.meta
Class DACC
- java.lang.Object
-
- moa.AbstractMOAObject
-
- moa.options.AbstractOptionHandler
-
- moa.classifiers.AbstractClassifier
-
- moa.classifiers.meta.DACC
-
- All Implemented Interfaces:
Configurable
,Serializable
,CapabilitiesHandler
,Classifier
,MultiClassClassifier
,AWTRenderable
,Learner<Example<Instance>>
,MOAObject
,OptionHandler
- Direct Known Subclasses:
ADACC
public class DACC extends AbstractClassifier implements MultiClassClassifier
Dynamic Adaptation to Concept Changes. Ensemble method for data streams that adapts to concept changes. Reference: JABER, G., CORNUEJOLS, A., and TARROUX, P. A New On-Line Learning Method for Coping with Recurring Concepts: The ADACC System. In : Neural Information Processing. Springer Berlin Heidelberg, 2013. p. 595-604.- Author:
- Ghazal Jaber (ghazal.jaber@gmail.com)
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
DACC.Pair
This helper class is used to sort an array of pairs of integers: val and index.
-
Field Summary
Fields Modifier and Type Field Description MultiChoiceOption
combinationOption
Combination functions: MAX and WVD (MAX leads to a faster reactivity to the change, WVD is more robust to noise)protected Classifier[]
ensemble
Ensemble of classifiersprotected double[]
ensembleAges
Age of classifiers (to compare with maturity age)protected DACC.Pair[]
ensembleWeights
Weights of classifiersprotected int[][]
ensembleWindows
Evaluation windows (recent classification errors)FloatOption
evaluationSizeOption
Size of the evaluation window for weights computingClassOption
learnerOption
Base classifierFloatOption
maturityOption
Maturity age of classifiersFloatOption
memberCountOption
Ensemble sizeprotected int
nbInstances
Number of instances from the stream-
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 DACC()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
discardModel(int index)
Resets a classifier in the ensembleprotected DACC.Pair[]
getHalf(boolean bestHalf)
Returns the best (or worst) half of classifiers in the adaptive ensemble.protected ArrayList<Integer>
getMAXIndexes()
Returns the classifiers that vote for the final prediction when the MAX combination function is selectedvoid
getModelDescription(StringBuilder out, int indent)
Returns a string representation of the model.protected Measurement[]
getModelMeasurementsImpl()
Gets the current measurements of this classifier.
The reason for ...Impl methods: ease programmer burden by not requiring them to remember calls to super in overridden methods.protected int
getNbActiveClassifiers()
Returns the number of classifiers used for prediction which includes the adaptive learners and the snapshots in ADACCprotected int
getNbAdaptiveClassifiers()
Returns the number of adaptive classifiers in the ensemble which excludes the static snapshots in ADACCString
getPurposeString()
Dictionary with option texts and objectsClassifier[]
getSubClassifiers()
Gets the classifiers of this ensemble.double[]
getVotesForInstance(Instance inst)
Predicts the class memberships for a given instance.protected ArrayList<Integer>
getWVDIndexes()
Returns the classifiers that vote for the final prediction when the WVD combination function is selectedprotected void
initVariables()
Initializes the method variablesboolean
isRandomizable()
Gets whether this learner needs a random seed.void
resetLearningImpl()
Resets this classifier.protected void
trainAndClassify(Instance inst)
Receives a training instance from the stream and updates the adaptive classifiers accordinglyvoid
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.protected double
updateEvaluationWindow(int index, int val)
Updates the evaluation window of a classifier and returns the updated weight value.-
Methods inherited from class moa.classifiers.AbstractClassifier
contextIsCompatible, copy, correctlyClassifies, defineImmutableCapabilities, getAttributeNameString, getAWTRenderer, getClassLabelString, getClassNameString, getDescription, getModel, getModelContext, getModelMeasurements, getNominalValueString, getPredictionForInstance, getPredictionForInstance, getSublearners, getVotesForInstance, modelAttIndexToInstanceAttIndex, modelAttIndexToInstanceAttIndex, prepareForUseImpl, 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
Base classifier
-
memberCountOption
public FloatOption memberCountOption
Ensemble size
-
maturityOption
public FloatOption maturityOption
Maturity age of classifiers
-
evaluationSizeOption
public FloatOption evaluationSizeOption
Size of the evaluation window for weights computing
-
combinationOption
public MultiChoiceOption combinationOption
Combination functions: MAX and WVD (MAX leads to a faster reactivity to the change, WVD is more robust to noise)
-
ensemble
protected Classifier[] ensemble
Ensemble of classifiers
-
ensembleWeights
protected DACC.Pair[] ensembleWeights
Weights of classifiers
-
ensembleAges
protected double[] ensembleAges
Age of classifiers (to compare with maturity age)
-
ensembleWindows
protected int[][] ensembleWindows
Evaluation windows (recent classification errors)
-
nbInstances
protected int nbInstances
Number of instances from the stream
-
-
Method Detail
-
getPurposeString
public String getPurposeString()
Description copied from class:AbstractOptionHandler
Dictionary with option texts and objects- Specified by:
getPurposeString
in interfaceOptionHandler
- Overrides:
getPurposeString
in classAbstractClassifier
- Returns:
- the string with the purpose of this object
-
initVariables
protected void initVariables()
Initializes the method variables
-
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
-
getVotesForInstance
public double[] getVotesForInstance(Instance inst)
Description copied from interface:Classifier
Predicts the class memberships for a given instance. If an instance is unclassified, the returned array elements must be all zero.- 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
-
trainAndClassify
protected void trainAndClassify(Instance inst)
Receives a training instance from the stream and updates the adaptive classifiers accordingly- Parameters:
inst
- the instance from the stream
-
discardModel
public void discardModel(int index)
Resets a classifier in the ensemble- Parameters:
index
- the index of the classifier in the ensemble
-
updateEvaluationWindow
protected double updateEvaluationWindow(int index, int val)
Updates the evaluation window of a classifier and returns the updated weight value.- Parameters:
index
- the index of the classifier in the ensembleval
- the last evaluation record of the classifier- Returns:
- the updated weight value of the classifier
-
getHalf
protected DACC.Pair[] getHalf(boolean bestHalf)
Returns the best (or worst) half of classifiers in the adaptive ensemble. The best classifiers are used to compute the stability index in ADACC. The worst classifiers are returned in order to select a classifier for deletion.- Parameters:
bestHalf
- boolean value set to true (false) if we want to return the best (worst) half of adaptive classifiers.- Returns:
- an array containing the weight values of the corresponding classifiers and their indexes in the ensemble.
-
getMAXIndexes
protected ArrayList<Integer> getMAXIndexes()
Returns the classifiers that vote for the final prediction when the MAX combination function is selected- Returns:
- the classifiers with the highest weight value
-
getWVDIndexes
protected ArrayList<Integer> getWVDIndexes()
Returns the classifiers that vote for the final prediction when the WVD combination function is selected- Returns:
- the classifiers whose weights lie in the higher half of the ensemble's weight interval.
-
getNbActiveClassifiers
protected int getNbActiveClassifiers()
Returns the number of classifiers used for prediction which includes the adaptive learners and the snapshots in ADACC- Returns:
- the number of classifiers used for prediction
-
getNbAdaptiveClassifiers
protected int getNbAdaptiveClassifiers()
Returns the number of adaptive classifiers in the ensemble which excludes the static snapshots in ADACC- Returns:
- the number of adaptive classifiers
-
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
-
getModelMeasurementsImpl
protected Measurement[] getModelMeasurementsImpl()
Description copied from class:AbstractClassifier
Gets the current measurements of this classifier.
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:
getModelMeasurementsImpl
in classAbstractClassifier
- Returns:
- an array of measurements to be used in evaluation tasks
-
isRandomizable
public boolean isRandomizable()
Description copied from interface:Learner
Gets whether this learner needs a random seed. Examples of methods that needs a random seed are bagging and boosting.- Specified by:
isRandomizable
in interfaceLearner<Example<Instance>>
- Returns:
- true if the learner needs a random seed.
-
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
-
-