Skip to content

Commit

Permalink
Adding Local Adaptive Streaming Tree (#1610)
Browse files Browse the repository at this point in the history
* add first last with out-of-date docs

* update LAST to detect change in the data distribution + iter_arff none class

Docs are also updated

* update docs

* Update hoeffding_adaptive_tree_classifier.py

* changes after tests

* solving inheritance and small fixes

* tests + current_merit method

* Update river/tree/hoeffding_adaptive_tree_classifier.py

* update docs

* change docs

* change last

* Update docs/releases/unreleased.md

* Update river/tree/hoeffding_adaptive_tree_classifier.py

* Update river/tree/last_classifier.py

* add disclamer

* Update river/tree/last_classifier.py

---------

Co-authored-by: Saulo Martiello Mastelini <saulomastelini@gmail.com>
  • Loading branch information
danielnowakassis and smastelini authored Sep 6, 2024
1 parent 7e3eb19 commit e3b2163
Show file tree
Hide file tree
Showing 12 changed files with 614 additions and 2 deletions.
6 changes: 6 additions & 0 deletions docs/releases/unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,9 @@
## tree

- Instead of letting trees grow indefinitely, setting the `max_depth` parameter to `None` will stop the trees from growing when they reach the system recursion limit.

-Added `tree.LASTClassifier` (Local Adaptive Streaming Tree Classifier).

## stream

- `stream.iter_arff` now supports blank values (treated as missing values).
7 changes: 5 additions & 2 deletions river/stream/iter_arff.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def iter_arff(
x = {
name: cast(val) if cast else val
for name, cast, val in zip(names, casts, r.rstrip().split(","))
if val != "?"
if val != "?" and val != ""
}

# Handle target
Expand All @@ -185,7 +185,10 @@ def iter_arff(
if isinstance(target, list):
y = {name: x.pop(name, 0) for name in target}
else:
y = x.pop(target) if target else None
try:
y = x.pop(target) if target else None
except KeyError:
y = None

yield x, y

Expand Down
2 changes: 2 additions & 0 deletions river/tree/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
from .hoeffding_tree_classifier import HoeffdingTreeClassifier
from .hoeffding_tree_regressor import HoeffdingTreeRegressor
from .isoup_tree_regressor import iSOUPTreeRegressor
from .last_classifier import LASTClassifier
from .stochastic_gradient_tree import SGTClassifier, SGTRegressor

__all__ = [
Expand All @@ -70,6 +71,7 @@
"HoeffdingTreeRegressor",
"HoeffdingAdaptiveTreeRegressor",
"iSOUPTreeRegressor",
"LASTClassifier",
"SGTClassifier",
"SGTRegressor",
]
Loading

0 comments on commit e3b2163

Please sign in to comment.