CapyMOA ensemble wrappers.
Incremental, mostly drift-aware ensembles backed by CapyMOA/MOA. Registered under
capymoa. hub keys, mirroring the native TuiML ensemble family.Classes
Adaptive Random Forest drift-aware classifier (hub key capymoa.AdaptiveRandomForest).
Wraps
AdaptiveRandomForestClassifier. An ensemble of Hoeffding Trees trained with online bagging and per-tree random feature subsets; each member carries a drift detector and is replaced by a background tree when its accuracy degrades.
Constructor
__init__( self, ensemble_size: int = 10, )
Parameters
ensemble_size
int
= 10
Number of trees in the forest. More trees improve accuracy at the cost of memory and per-instance training time.
Attributes
schema_
capymoa.stream.Schema
Stream schema derived from the training data.
learner_
capymoa.classifier.AdaptiveRandomForestClassifier
The fitted backing CapyMOA learner.
Notes
Requires the optional CapyMOA extra:
pip install 'tuiml[capymoa]'. The strongest general-purpose choice among the CapyMOA classifiers wrapped here, especially under concept drift.See Also
python
>>> from tuiml.capymoa import AdaptiveRandomForest
>>> from tuiml.datasets.generators import Hyperplane
>>> data = Hyperplane(n_samples=1000, n_drift_features=2,
... random_state=42).generate()
>>> model = AdaptiveRandomForest(ensemble_size=5).fit(data.X, data.y)
>>> model.predict(data.X[:5]).shape
(5,)
Online Bagging (Oza & Russell) ensemble classifier (hub key capymoa.OnlineBagging).
Wraps
OnlineBagging. Simulates bootstrap sampling on a stream by training each ensemble member on every instance k times, with k \sim \text{Poisson}(1).
Constructor
__init__( self, ensemble_size: int = 10, )
Parameters
ensemble_size
int
= 10
Number of base learners in the ensemble.
Attributes
schema_
capymoa.stream.Schema
Stream schema derived from the training data.
learner_
capymoa.classifier.OnlineBagging
The fitted backing CapyMOA learner.
Notes
Requires the optional CapyMOA extra:
pip install 'tuiml[capymoa]'. No built-in drift handling; for drifting streams prefer LeveragingBagging or AdaptiveRandomForest.
python
>>> from tuiml.capymoa import OnlineBagging
>>> from tuiml.datasets.generators import Agrawal
>>> data = Agrawal(n_samples=1000, function=1, random_state=42).generate()
>>> model = OnlineBagging(ensemble_size=5).fit(data.X, data.y)
>>> model.predict(data.X[:5]).shape
(5,)
Leveraging Bagging drift-aware ensemble classifier (hub key capymoa.LeveragingBagging).
Wraps
LeveragingBagging. Extends online bagging with higher resampling weights (\text{Poisson}(6)) for more input diversity, plus ADWIN drift detection that resets underperforming ensemble members.
Constructor
__init__( self, ensemble_size: int = 10, )
Parameters
ensemble_size
int
= 10
Number of base learners in the ensemble.
Attributes
schema_
capymoa.stream.Schema
Stream schema derived from the training data.
learner_
capymoa.classifier.LeveragingBagging
The fitted backing CapyMOA learner.
Notes
Requires the optional CapyMOA extra:
pip install 'tuiml[capymoa]'.See Also
python
>>> from tuiml.capymoa import LeveragingBagging
>>> from tuiml.datasets.generators import Hyperplane
>>> data = Hyperplane(n_samples=1000, n_drift_features=2,
... random_state=42).generate()
>>> model = LeveragingBagging(ensemble_size=5).fit(data.X, data.y)
>>> model.predict(data.X[:5]).shape
(5,)
class capymoa.ensemble.AdaptiveRandomForestRegressor(_CapyMOAStreamMixin, Regressor)
Adaptive Random Forest drift-aware regressor (hub key capymoa.AdaptiveRandomForestRegressor).
Wraps
AdaptiveRandomForestRegressor. The regression counterpart of the Adaptive Random Forest: an ensemble of FIMT-DD trees with online bagging, random feature subsets, and per-member drift detection.
Constructor
__init__( self, ensemble_size: int = 10, )
Parameters
ensemble_size
int
= 10
Number of trees in the forest.
Attributes
schema_
capymoa.stream.Schema
Stream schema derived from the training data.
learner_
capymoa.regressor.AdaptiveRandomForestRegressor
The fitted backing CapyMOA learner.
Notes
Requires the optional CapyMOA extra:
pip install 'tuiml[capymoa]'.
python
>>> from tuiml.capymoa import AdaptiveRandomForestRegressor
>>> from tuiml.datasets.generators import Friedman
>>> data = Friedman(n_samples=1000, random_state=42).generate()
>>> model = AdaptiveRandomForestRegressor(ensemble_size=5).fit(data.X, data.y)
>>> model.predict(data.X[:5]).shape
(5,)