Package moa.classifiers.meta
Class StreamingRandomPatches
- java.lang.Object
-
- moa.AbstractMOAObject
-
- moa.options.AbstractOptionHandler
-
- moa.classifiers.AbstractClassifier
-
- moa.classifiers.meta.StreamingRandomPatches
-
- All Implemented Interfaces:
Configurable
,Serializable
,CapabilitiesHandler
,Classifier
,MultiClassClassifier
,AWTRenderable
,Learner<Example<Instance>>
,MOAObject
,OptionHandler
public class StreamingRandomPatches extends AbstractClassifier implements MultiClassClassifier, CapabilitiesHandler
Streaming Random PatchesStreaming Random Patches (SRP). This ensemble method uses a hoeffding tree by default, but it can be used with any other base model (differently from random forest variations). This algorithm can be used to simulate bagging or random subspaces, see parameter -t. The default algorithm uses both bagging and random subspaces, namely Random Patches.
See details in:
Heitor Murilo Gomes, Jesse Read, Albert Bifet. Streaming Random Patches for Evolving Data Stream Classification. IEEE International Conference on Data Mining (ICDM), 2019.Parameters:
- -l : Classifier to train. Default to a Hoeffding Tree, but it is not restricted to decision trees.
- -s : The number of learners in the ensemble.
- -o : How the number of features is interpreted (4 options): "Specified m (integer value)", "sqrt(M)+1", "M-(sqrt(M)+1)".
- -m : Number of features allowed considered for each split. Negative values corresponds to M - m.
- -t : The training method to use: Random Patches, Random Subspaces or Bagging.
- -a : The lambda value for the poisson distribution (used to emulate bagging).
- -x : Change detector for drifts and its parameters.
- -p : Change detector for warnings.
- -w : Should use weighted voting?
- -u : Should use drift detection? If disabled, then the bkg learner is also disabled.
- -q : Should use bkg learner? If disabled, then trees are reset immediately.
- Version:
- $Revision: 1 $
- Author:
- Heitor Murilo Gomes (heitor dot gomes at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
StreamingRandomPatches.StreamingRandomPatchesClassifier
-
Field Summary
Fields Modifier and Type Field Description ClassOption
baseLearnerOption
FlagOption
disableBackgroundLearnerOption
FlagOption
disableDriftDetectionOption
FlagOption
disableWeightedVote
ClassOption
driftDetectionMethodOption
protected StreamingRandomPatches.StreamingRandomPatchesClassifier[]
ensemble
IntOption
ensembleSizeOption
protected static int
FEATURES_M
protected static int
FEATURES_PERCENT
protected static int
FEATURES_SQRT
protected static int
FEATURES_SQRT_INV
protected long
instancesSeen
FloatOption
lambdaOption
MultiChoiceOption
subspaceModeOption
protected ArrayList<ArrayList<Integer>>
subspaces
IntOption
subspaceSizeOption
static int
TRAIN_RANDOM_PATCHES
static int
TRAIN_RANDOM_SUBSPACES
static int
TRAIN_RESAMPLING
MultiChoiceOption
trainingMethodOption
ClassOption
warningDetectionMethodOption
-
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 StreamingRandomPatches()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ArrayList<ArrayList<Integer>>
allKCombinations(int k, int length)
ImmutableCapabilities
defineImmutableCapabilities()
Defines the set of capabilities the object has.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.Classifier[]
getSublearners()
Gets the learners of this ensemble.double[]
getVotesForInstance(Instance instance)
Predicts the class memberships for a given instance.protected void
initEnsemble(Instance instance)
boolean
isRandomizable()
Gets whether this learner needs a random seed.static ArrayList<ArrayList<Integer>>
localRandomKCombinations(int k, int length, int nCombinations, Random random)
void
resetLearningImpl()
Resets this classifier.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, getAttributeNameString, getAWTRenderer, getClassLabelString, getClassNameString, getDescription, getModel, getModelContext, getModelMeasurements, getNominalValueString, getPredictionForInstance, getPredictionForInstance, getPurposeString, getSubClassifiers, 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
-
baseLearnerOption
public ClassOption baseLearnerOption
-
ensembleSizeOption
public IntOption ensembleSizeOption
-
subspaceModeOption
public MultiChoiceOption subspaceModeOption
-
subspaceSizeOption
public IntOption subspaceSizeOption
-
trainingMethodOption
public MultiChoiceOption trainingMethodOption
-
lambdaOption
public FloatOption lambdaOption
-
driftDetectionMethodOption
public ClassOption driftDetectionMethodOption
-
warningDetectionMethodOption
public ClassOption warningDetectionMethodOption
-
disableWeightedVote
public FlagOption disableWeightedVote
-
disableDriftDetectionOption
public FlagOption disableDriftDetectionOption
-
disableBackgroundLearnerOption
public FlagOption disableBackgroundLearnerOption
-
TRAIN_RANDOM_SUBSPACES
public static final int TRAIN_RANDOM_SUBSPACES
- See Also:
- Constant Field Values
-
TRAIN_RESAMPLING
public static final int TRAIN_RESAMPLING
- See Also:
- Constant Field Values
-
TRAIN_RANDOM_PATCHES
public static final int TRAIN_RANDOM_PATCHES
- See Also:
- Constant Field Values
-
FEATURES_M
protected static final int FEATURES_M
- See Also:
- Constant Field Values
-
FEATURES_SQRT
protected static final int FEATURES_SQRT
- See Also:
- Constant Field Values
-
FEATURES_SQRT_INV
protected static final int FEATURES_SQRT_INV
- See Also:
- Constant Field Values
-
FEATURES_PERCENT
protected static final int FEATURES_PERCENT
- See Also:
- Constant Field Values
-
ensemble
protected StreamingRandomPatches.StreamingRandomPatchesClassifier[] ensemble
-
instancesSeen
protected long instancesSeen
-
-
Method Detail
-
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
-
initEnsemble
protected void initEnsemble(Instance instance)
-
defineImmutableCapabilities
public ImmutableCapabilities defineImmutableCapabilities()
Description copied from interface:CapabilitiesHandler
Defines the set of capabilities the object has. Should be overridden if the object's capabilities do not change.- Specified by:
defineImmutableCapabilities
in interfaceCapabilitiesHandler
- Overrides:
defineImmutableCapabilities
in classAbstractClassifier
- Returns:
- The capabilities of the object.
-
getSublearners
public Classifier[] getSublearners()
Description copied from interface:Learner
Gets the learners of this ensemble. Returns null if this learner is a single learner.- Specified by:
getSublearners
in interfaceLearner<Example<Instance>>
- Overrides:
getSublearners
in classAbstractClassifier
- Returns:
- an array of the learners of the ensemble
-
localRandomKCombinations
public static ArrayList<ArrayList<Integer>> localRandomKCombinations(int k, int length, int nCombinations, Random random)
-
-