Skip to content

refactor(tree,ensemble): address review follow-ups from #467 - #468

Merged
Mec-iS merged 1 commit into
mainfrom
follow-up/467-review-notes
Sep 27, 2026
Merged

Mec-iS merged 1 commit into
mainfrom
follow-up/467-review-notes

Conversation

@Mec-iS

@Mec-iS Mec-iS commented Sep 27, 2026

Copy link
Copy Markdown
Collaborator

Follow-up to #467. Applies the three inline notes from the review.

Checklist

  • My branch is up-to-date with main branch.
  • Everything works and tested on latest stable Rust.
  • Coverage and Linting have been applied

Current behaviour

Three review notes on #467 stayed open: find_best_cutoff recomputes the node mass on every entry (one O(n) pass per node); a test comment says "No bootstrapping" where bootstrap: true is set; validate_sample_weights is pub(crate) in base_tree_regressor, so an internal helper leaks into three modules.

New expected behaviour

  • mass is passed down like the other split statistics: fit_weak_learner gives the root mass to find_best_cutoff; split accumulates the child masses in the existing partition loop and hands them to the recursive find_best_cutoff calls. The re-computation block is removed.
  • The test comment now reads "Use bootstrapping".
  • validate_sample_weights is private to each entry-point module (decision_tree_regressor, random_forest_regressor, extra_trees_regressor). No shared helper crosses module bounds.

Numerical behaviour is unchanged: same values and summation order on every path. cargo test --all-features passes (554 unit tests + doctests), cargo clippy --all-features -- -Drust-2018-idioms -Drust-2024-compatibility -Dwarnings and cargo fmt --all -- --check are clean.

Change logs

Changed

  • tree: BaseTreeRegressor::find_best_cutoff takes the node mass as a parameter. The root mass comes from fit_weak_learner; child masses are accumulated in split during the sample partition. Internal API only.
  • tree, ensemble: validate_sample_weights is private to each of the three entry-point modules instead of pub(crate) in base_tree_regressor. Internal API only.

@Mec-iS
Mec-iS merged commit 80ea853 into main Sep 27, 2026
13 checks passed
@Mec-iS
Mec-iS deleted the follow-up/467-review-notes branch September 27, 2026 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant