API Reference / capymoa /

trees.py

CapyMOA trees wrappers.

Incremental (Hoeffding-bound based) decision trees backed by CapyMOA/MOA. Registered under capymoa. hub keys, mirroring the native TuiML trees family.

Classes

HoeffdingTree

class capymoa.trees.HoeffdingTree(_CapyMOAStreamMixin, Classifier)

Hoeffding Tree (VFDT) incremental classifier (hub key capymoa.HoeffdingTree).

Wraps HoeffdingTree. Grows a decision tree one instance at a time, using the Hoeffding bound to decide when enough instances have been seen to commit to a split — no need to store or revisit past data.
Constructor
__init__(
    self,
    grace_period: int = 200,
)

Parameters

grace_period
int = 200
Number of instances a leaf must observe between split attempts. Smaller values adapt faster but cost more computation.

Attributes

schema_
capymoa.stream.Schema
Stream schema derived from the training data.
learner_
capymoa.classifier.HoeffdingTree
The fitted backing CapyMOA learner.

Notes

Requires the optional CapyMOA extra: pip install 'tuiml[capymoa]'. The classic single-model streaming learner; assumes a mostly stationary stream. For drifting streams prefer HoeffdingAdaptiveTree or AdaptiveRandomForest.
python
>>> from tuiml.capymoa import HoeffdingTree
>>> from tuiml.datasets.generators import Agrawal
>>> data = Agrawal(n_samples=1000, function=2, random_state=42).generate()
>>> model = HoeffdingTree(grace_period=100).fit(data.X, data.y)
>>> model.predict(data.X[:5]).shape
(5,)

Methods

get_parameter_schema (cls) -> Dict[str, Any]

Return JSON Schema for constructor parameters.

get_capabilities (cls) -> List[str]

Return the capability names this wrapper supports.

HoeffdingAdaptiveTree

class capymoa.trees.HoeffdingAdaptiveTree(_CapyMOAStreamMixin, Classifier)

Hoeffding Adaptive Tree (HAT) drift-aware classifier (hub key capymoa.HoeffdingAdaptiveTree).

Wraps HoeffdingAdaptiveTree. Extends the Hoeffding Tree with ADWIN drift detectors at internal nodes: when a subtree's accuracy degrades, an alternate subtree is grown in the background and swapped in once it performs better.
Constructor
__init__(
    self,
    grace_period: int = 200,
)

Parameters

grace_period
int = 200
Number of instances a leaf must observe between split attempts.

Attributes

schema_
capymoa.stream.Schema
Stream schema derived from the training data.
learner_
capymoa.classifier.HoeffdingAdaptiveTree
The fitted backing CapyMOA learner.

Notes

Requires the optional CapyMOA extra: pip install 'tuiml[capymoa]'. Prefer this over the plain HoeffdingTree when the data distribution is expected to change over time.
python
>>> from tuiml.capymoa import HoeffdingAdaptiveTree
>>> from tuiml.datasets.generators import Hyperplane
>>> data = Hyperplane(n_samples=1000, n_drift_features=2,
...                   random_state=42).generate()
>>> model = HoeffdingAdaptiveTree().fit(data.X, data.y)
>>> model.predict(data.X[:5]).shape
(5,)

Methods

get_parameter_schema (cls) -> Dict[str, Any]

Return JSON Schema for constructor parameters.

get_capabilities (cls) -> List[str]

Return the capability names this wrapper supports.

EFDT

class capymoa.trees.EFDT(_CapyMOAStreamMixin, Classifier)

Extremely Fast Decision Tree classifier (hub key capymoa.EFDT).

Wraps EFDT. A Hoeffding Tree variant that splits as soon as a split looks useful rather than provably best, then keeps re-evaluating and revising splits as more data arrives — converging to the batch tree faster than VFDT.
Constructor
__init__(
    self,
    grace_period: int = 200,
)

Parameters

grace_period
int = 200
Number of instances a leaf must observe between split attempts.

Attributes

schema_
capymoa.stream.Schema
Stream schema derived from the training data.
learner_
capymoa.classifier.EFDT
The fitted backing CapyMOA learner.

Notes

Requires the optional CapyMOA extra: pip install 'tuiml[capymoa]'.
python
>>> from tuiml.capymoa import EFDT
>>> from tuiml.datasets.generators import Agrawal
>>> data = Agrawal(n_samples=1000, function=3, random_state=42).generate()
>>> model = EFDT().fit(data.X, data.y)
>>> model.predict(data.X[:5]).shape
(5,)

Methods

get_parameter_schema (cls) -> Dict[str, Any]

Return JSON Schema for constructor parameters.

get_capabilities (cls) -> List[str]

Return the capability names this wrapper supports.

FIMTDD

class capymoa.trees.FIMTDD(_CapyMOAStreamMixin, Regressor)

FIMT-DD streaming regression tree (hub key capymoa.FIMTDD).

Wraps FIMTDD. Fast Incremental Model Tree with Drift Detection: grows a regression tree incrementally, fits linear models in the leaves, and replaces subtrees when drift is detected.
Constructor
__init__(
    self,
)

Attributes

schema_
capymoa.stream.Schema
Stream schema derived from the training data.
learner_
capymoa.regressor.FIMTDD
The fitted backing CapyMOA learner.

Notes

Requires the optional CapyMOA extra: pip install 'tuiml[capymoa]'.
python
>>> from tuiml.capymoa import FIMTDD
>>> from tuiml.datasets.generators import Friedman
>>> data = Friedman(n_samples=1000, random_state=42).generate()
>>> model = FIMTDD().fit(data.X, data.y)
>>> model.predict(data.X[:5]).shape
(5,)

Methods

__init__ (self)
get_parameter_schema (cls) -> Dict[str, Any]

Return JSON Schema for constructor parameters.

get_capabilities (cls) -> List[str]

Return the capability names this wrapper supports.