Skip to content

Commit a16d0f1

Browse files
kulbachcedrice10e3
andauthored
Fix division error in inactive leaf size estimation (#1721)
* Fix division error in inactive leaf size estimation * Change line * Add check for zero devision * Add release notes * unreleased.md aktualisieren Co-authored-by: Émile <73942755+e10e3@users.noreply.github.com> --------- Co-authored-by: Émile <73942755+e10e3@users.noreply.github.com>
1 parent 10582f1 commit a16d0f1

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

docs/releases/unreleased.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,7 @@
44

55
- Added `update_many` method to `stats.PearsonCorr`.
66
- Changed the calculation of the Kuiper statistic in `base.KolmogorovSmirnov` to correspond to the reference implementation. The Kuiper statistic uses the difference between the maximum value and the minimum value.
7+
8+
## tree
9+
10+
- Added handling for division by zero in `tree.hoeffding_tree` for leaf size estimation.

river/tree/hoeffding_tree.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,9 +296,9 @@ def _estimate_model_size(self):
296296
total_active_size += calculate_object_size(leaf)
297297
else:
298298
total_inactive_size += calculate_object_size(leaf)
299-
if total_active_size > 0:
299+
if total_active_size > 0 and self._n_active_leaves > 0:
300300
self._active_leaf_size_estimate = total_active_size / self._n_active_leaves
301-
if total_inactive_size > 0:
301+
if total_inactive_size > 0 and self._n_inactive_leaves > 0:
302302
self._inactive_leaf_size_estimate = total_inactive_size / self._n_inactive_leaves
303303
actual_model_size = calculate_object_size(self)
304304
estimated_model_size = (

0 commit comments

Comments
 (0)