StreamingRandomPatches#

class capymoa.classifier.StreamingRandomPatches[source]#

Bases: MOAClassifier

Streaming Random Patches (SRP) Classifier

Streaming 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 training_method. The default algorithm uses both bagging and random subspaces, namely Random Patches.

Reference:

Streaming Random Patches for Evolving Data Stream Classification. Heitor Murilo Gomes, Jesse Read, Albert Bifet. IEEE International Conference on Data Mining (ICDM), 2019.

Example usages:

>>> from capymoa.datasets import ElectricityTiny
>>> from capymoa.classifier import StreamingRandomPatches
>>> from capymoa.evaluation import prequential_evaluation
>>> stream = ElectricityTiny()
>>> schema = stream.get_schema()
>>> learner = StreamingRandomPatches(schema)
>>> results = prequential_evaluation(stream, learner, max_instances=1000)
>>> results["cumulative"].accuracy()
89.7
__init__(
schema: Schema | None = None,
random_seed: int = 0,
base_learner='trees.HoeffdingTree -g 50 -c 0.01',
ensemble_size=100,
max_features=0.6,
training_method: str = 'RandomPatches',
lambda_param: float = 6.0,
drift_detection_method='ADWINChangeDetector -a 1.0E-5',
warning_detection_method='ADWINChangeDetector -a 1.0E-4',
disable_weighted_vote: bool = False,
disable_drift_detection: bool = False,
disable_background_learner: bool = False,
)[source]#

Streaming Random Patches (SRP) Classifier

Parameters:
  • schema – The schema of the stream.

  • random_seed – The random seed passed to the MOA learner.

  • base_learner – The base learner to be trained. Default trees.HoeffdingTree -g 50 -c 0.01.

  • ensemble_size – The number of trees in the ensemble.

  • max_features – The maximum number of features to consider when splitting a node. If provided as a float between 0.0 and 1.0, it represents the percentage of features to consider. If provided as an integer, it specifies the exact number of features to consider. If provided as the string “sqrt”, it indicates that the square root of the total number of features. If not provided, the default value is 60%.

  • training_method – The training method to use: RandomSubspaces, Resampling or RandomPatches. RandomSubspaces: Random Subspaces. Resampling: Resampling (bagging). RandomPatches: Random Patches.

  • lambda_param – The lambda parameter that controls the Poisson distribution for the online bagging simulation.

  • drift_detection_method – The method used for drift detection.

  • warning_detection_method – The method used for warning detection.

  • disable_weighted_vote – Whether to disable weighted voting.

  • disable_drift_detection – Whether to disable drift detection.

  • disable_background_learner – Whether to disable background learning.

CLI_help()[source]#
predict(instance)[source]#
predict_proba(instance)[source]#
train(instance)[source]#