Skip to content

Commit

Permalink
Fix #1560 (ARF cornercase)
Browse files Browse the repository at this point in the history
  • Loading branch information
smastelini authored Jun 28, 2024
1 parent 6995f15 commit c8ea67f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions docs/releases/unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ This release makes Polars an optional dependency instead of a required one.
## cluster

- Added `ODAC` (Online Divisive-Agglomerative Clustering) for clustering time series.

## forest

- Fix error in `forest.ARFClassifer` and `forest.ARFRegressor` where the algorithms would crash in case the number of features available for learning went below the value of the `max_features` parameter (#1560).
4 changes: 3 additions & 1 deletion river/tree/nodes/arf_htc_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ def _iter_features(self, x) -> typing.Iterable:
yield att_id, x[att_id]

def _sample_features(self, x, max_features):
return self.rng.sample(sorted(x.keys()), k=max_features)
if len(x) >= max_features:
return self.rng.sample(sorted(x.keys()), k=max_features)
return sorted(x.keys())


class RandomLeafMajorityClass(BaseRandomLeaf, LeafMajorityClass):
Expand Down

0 comments on commit c8ea67f

Please sign in to comment.