Implementation:Online ml River Tree Nodes EFDTC
| Knowledge Sources | |
|---|---|
| Domains | Online_Learning, Decision_Trees |
| Last Updated | 2026-02-08 16:00 GMT |
Overview
EFDT (Extremely Fast Decision Tree) node implementations for classification tasks that support both learning and splitting operations simultaneously.
Description
This module implements the specialized nodes for EFDT classifiers in River. EFDT is unique among Hoeffding Trees because split nodes continue learning from incoming samples and can reevaluate split decisions over time. The module provides both leaf nodes (EFDTLeafMajorityClass, EFDTLeafNaiveBayes, EFDTLeafNaiveBayesAdaptive) and branch nodes (EFDTNominalBinaryBranch, EFDTNominalMultiwayBranch, EFDTNumericBinaryBranch, EFDTNumericMultiwayBranch) that inherit from base classes BaseEFDTLeaf and BaseEFDTBranch.
Usage
Use EFDT nodes when building extremely fast decision tree classifiers that need to adapt quickly to concept drift by revisiting split decisions. These nodes are ideal for high-speed data streams where rapid model updates are critical.
Code Reference
Source Location
- Repository: Online_ml_River
- File: river/tree/nodes/efdtc_nodes.py
Signature
class BaseEFDTLeaf(HTLeaf):
def __init__(self, stats, depth, splitter, **kwargs):
...
def best_split_suggestions(self, criterion, tree):
...
class BaseEFDTBranch(DTBranch):
def __init__(self, stats, *children, splitter, splitters, **attributes):
...
def learn_one(self, x, y, *, w=1.0, tree=None):
...
def best_split_suggestions(self, criterion, tree):
...
class EFDTLeafMajorityClass(BaseEFDTLeaf, LeafMajorityClass):
...
class EFDTLeafNaiveBayes(BaseEFDTLeaf, LeafNaiveBayes):
...
class EFDTLeafNaiveBayesAdaptive(BaseEFDTLeaf, LeafNaiveBayesAdaptive):
...
Import
from river.tree.nodes.efdtc_nodes import EFDTLeafMajorityClass
from river.tree.nodes.efdtc_nodes import EFDTLeafNaiveBayes
from river.tree.nodes.efdtc_nodes import BaseEFDTBranch
I/O Contract
| Input | Type | Description |
|---|---|---|
| stats | dict | Class observations dictionary |
| depth | int | Node depth in the tree |
| splitter | Splitter | Numeric attribute observer for monitoring statistics |
| Output | Type | Description |
|---|---|---|
| prediction | dict | Normalized class probability distribution |
| split_suggestions | list[BranchFactory] | Candidate splits for the node |
Usage Examples
from river.tree.nodes.efdtc_nodes import EFDTLeafMajorityClass
from river.tree.splitter import GaussianSplitter
# Create an EFDT leaf node
leaf = EFDTLeafMajorityClass(
stats={0: 10, 1: 15},
depth=2,
splitter=GaussianSplitter()
)
# Update the leaf with new samples
x = {'feature1': 0.5, 'feature2': 1.2}
leaf.learn_one(x, y=1, w=1.0, tree=None)
# Get predictions
prediction = leaf.prediction(x, tree=None)
# EFDT branches can also learn
from river.tree.nodes.efdtc_nodes import EFDTNumericBinaryBranch
# Branches continue learning as data passes through