Package moa.classifiers.meta.imbalanced
Class CSMOTE
- java.lang.Object
-
- moa.AbstractMOAObject
-
- moa.options.AbstractOptionHandler
-
- moa.classifiers.AbstractClassifier
-
- moa.classifiers.meta.imbalanced.CSMOTE
-
- All Implemented Interfaces:
Configurable
,Serializable
,CapabilitiesHandler
,Classifier
,MultiClassClassifier
,AWTRenderable
,Learner<Example<Instance>>
,MOAObject
,OptionHandler
public class CSMOTE extends AbstractClassifier implements MultiClassClassifier
CSMOTEThis strategy save all the minority samples in a window managed by ADWIN. In the meantime, a model is trained with the data in input. When the minority sample ratio is less than a certain threshold, an online SMOTE version is applied. A random minority sample is chosen from the window and a new synthetic sample is generated until the minority sample ratio is greater or equal than the threshold. The model is then trained with the new samples generated.
See details in:
Alessio Bernardo, Heitor Murilo Gomes, Jacob Montiel, Bernhard Pfharinger, Albert Bifet, Emanuele Della Valle. C-SMOTE: Continuous Synthetic Minority Oversampling for Evolving Data Streams. In BigData, IEEE, 2020.Parameters:
- -l : Classifier to train. Default is ARF
- -k : Number of neighbors for SMOTE. Default is 5
- -t : Threshold for the minority samples. Default is 0.5
- -m : Minimum number of samples in the minority class for applying SMOTE. Default is 100
- -d : Should use ADWIN as drift detector? If enabled it is used by the method to track the performance of the classifiers and adapt when a drift is detected.
- Version:
- $Revision: 1 $
- Author:
- Alessio Bernardo (alessio dot bernardo at polimi dot com)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected ADWIN
adwin
protected ADWIN
adwinDriftDetector
protected ArrayList<Integer>
alreadyUsed
ClassOption
baseLearnerOption
FlagOption
disableDriftDetectionOption
protected boolean
driftDetection
protected int[]
indexValues
protected HashMap<Instance,Integer>
instanceGenerated
protected Classifier
learner
protected Instances
maj
protected Instances
min
protected int
minSizeAllowed
IntOption
minSizeAllowedOption
protected int
neighbors
IntOption
neighborsOption
protected int
nGeneratedMajorityTotal
protected int
nGeneratedMinorityTotal
protected int
nMajorityTotal
protected int
nMinorityTotal
protected SamoaToWekaInstanceConverter
samoaToWeka
protected double
threshold
FloatOption
thresholdOption
protected ArrayList<Instance>
W
protected WekaToSamoaInstanceConverter
wekaToSamoa
-
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 CSMOTE()
-
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
-
neighborsOption
public IntOption neighborsOption
-
thresholdOption
public FloatOption thresholdOption
-
minSizeAllowedOption
public IntOption minSizeAllowedOption
-
disableDriftDetectionOption
public FlagOption disableDriftDetectionOption
-
learner
protected Classifier learner
-
neighbors
protected int neighbors
-
threshold
protected double threshold
-
minSizeAllowed
protected int minSizeAllowed
-
driftDetection
protected boolean driftDetection
-
adwin
protected ADWIN adwin
-
adwinDriftDetector
protected ADWIN adwinDriftDetector
-
min
protected Instances min
-
maj
protected Instances maj
-
nMinorityTotal
protected int nMinorityTotal
-
nMajorityTotal
protected int nMajorityTotal
-
nGeneratedMinorityTotal
protected int nGeneratedMinorityTotal
-
nGeneratedMajorityTotal
protected int nGeneratedMajorityTotal
-
samoaToWeka
protected SamoaToWekaInstanceConverter samoaToWeka
-
wekaToSamoa
protected WekaToSamoaInstanceConverter wekaToSamoa
-
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
-
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
-
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
-
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
-
-