Class RebalanceStream
- java.lang.Object
-
- moa.AbstractMOAObject
-
- moa.options.AbstractOptionHandler
-
- moa.classifiers.AbstractClassifier
-
- moa.classifiers.meta.imbalanced.RebalanceStream
-
- All Implemented Interfaces:
Configurable
,Serializable
,CapabilitiesHandler
,Classifier
,MultiClassClassifier
,AWTRenderable
,Learner<Example<Instance>>
,MOAObject
,OptionHandler
public class RebalanceStream extends AbstractClassifier implements MultiClassClassifier
RebalanceStreamThe RebalanceStream algorithm trains a model called learner as the standard algorithm implementation. Moreover, it saves every new data in input in a batch. If ADWIN detects a warning level, it starts saving the new data in input also in another batch called resetBatch. Then, when ADWIN detects a change, so there is a concept drift, it trains in parallel 3 models called learnerBal, learnerReset, learnerResetBal. The learnerBal model uses the batch data rebalanced by SMOTE, the learnerReset model uses the resetBatch data and the learnerResetBal model uses the resetBatch data rebalanced by SMOTE. Then the best model based on k-statistic is chosen to continue the experiment with a new sample.
See details in:
Alessio Bernardo, Albert Bifet, Emanuele Della Valle. Incremental Rebalancing Learning \\on Evolving Data Streams. In ICDM Workshop, 2020.Parameters:
- -l : Classifier to train. Default is TemporallyAugmentedClassifier
- -c : Minimum number of samples in the batch for applying SMOTE. Default is -1 (no limit)
- -g : Maximum number of samples in the batch for applying SMOTE. Default is -1 (no limit)
- -h : Minimum number of samples in the ResetBatch for applying SMOTE. Default is -1 (no limit)
- -g : Maximum number of samples in the ResetBatch for applying SMOTE. Default is -1 (no limit)
- Version:
- $Revision: 1 $
- Author:
- Alessio Bernardo (alessio dot bernardo at polimi dot com)
- See Also:
- Serialized Form
-
-
Field Summary
-
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 RebalanceStream()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
getModelDescription(StringBuilder arg0, int arg1)
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.String
getPurposeString()
Dictionary with option texts and objectsdouble[]
getVotesForInstance(Instance instance)
Predicts the class memberships for a given instance.boolean
isRandomizable()
Gets whether this learner needs a random seed.void
resetLearningImpl()
Resets this classifier.String
toString()
Returns a description of the object.void
trainOnInstanceImpl(Instance instance)
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, getSubClassifiers, 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
-
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
-
baseLearnerOption
public ClassOption baseLearnerOption
-
minInstanceLimitBatchOption
public IntOption minInstanceLimitBatchOption
-
maxInstanceLimitBatchOption
public IntOption maxInstanceLimitBatchOption
-
minInstanceLimitResetBatchOption
public IntOption minInstanceLimitResetBatchOption
-
maxInstanceLimitResetBatchOption
public IntOption maxInstanceLimitResetBatchOption
-
learner
protected Classifier learner
-
learnerResetBal
protected Classifier learnerResetBal
-
learnerReset
protected Classifier learnerReset
-
learnerBal
protected Classifier learnerBal
-
adwin
protected ADWIN adwin
-
nAttributes
protected int nAttributes
-
minInstanceLimitBatch
protected int minInstanceLimitBatch
-
maxInstanceLimitBatch
protected int maxInstanceLimitBatch
-
minInstanceLimitResetBatch
protected int minInstanceLimitResetBatch
-
maxInstanceLimitResetBatch
protected int maxInstanceLimitResetBatch
-
confusionMatrixLearner
protected int[][] confusionMatrixLearner
-
accLearner
protected double accLearner
-
kStatLearner
protected double kStatLearner
-
confusionMatrixResetBal
protected int[][] confusionMatrixResetBal
-
accResetBal
protected double accResetBal
-
kStatResetBal
protected double kStatResetBal
-
confusionMatrixReset
protected int[][] confusionMatrixReset
-
accReset
protected double accReset
-
kStatReset
protected double kStatReset
-
confusionMatrixBal
protected int[][] confusionMatrixBal
-
accBal
protected double accBal
-
kStatBal
protected double kStatBal
-
modelInUse
protected double modelInUse
-
nMinorityTotal
protected int nMinorityTotal
-
nMajorityTotal
protected int nMajorityTotal
-
nGeneratedMinorityTotal
protected int nGeneratedMinorityTotal
-
nGeneratedMajorityTotal
protected int nGeneratedMajorityTotal
-
effectiveNearestNeighbors
protected int effectiveNearestNeighbors
-
minorityInstances
protected weka.core.Instances minorityInstances
-
vdmMap
protected Map vdmMap
-
indexValues
protected int[] indexValues
-
-
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
-
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 instance)
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:
instance
- the instance to be used for training
-
getVotesForInstance
public double[] getVotesForInstance(Instance instance)
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:
instance
- the instance to be classified- Returns:
- an array containing the estimated membership probabilities of the test instance in each class
-
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.
-
getModelDescription
public void getModelDescription(StringBuilder arg0, int arg1)
Description copied from class:AbstractClassifier
Returns a string representation of the model.- Specified by:
getModelDescription
in classAbstractClassifier
- Parameters:
arg0
- the stringbuilder to add the descriptionarg1
- 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
-
toString
public String toString()
Description copied from class:AbstractMOAObject
Returns a description of the object.- Overrides:
toString
in classAbstractMOAObject
- Returns:
- a description of the object
-
-