refactor(tree,ensemble): address review follow-ups from #467 - #468
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #467. Applies the three inline notes from the review.
Checklist
Current behaviour
Three review notes on #467 stayed open:
find_best_cutoffrecomputes the nodemasson every entry (one O(n) pass per node); a test comment says "No bootstrapping" wherebootstrap: trueis set;validate_sample_weightsispub(crate)inbase_tree_regressor, so an internal helper leaks into three modules.New expected behaviour
massis passed down like the other split statistics:fit_weak_learnergives the root mass tofind_best_cutoff;splitaccumulates the child masses in the existing partition loop and hands them to the recursivefind_best_cutoffcalls. The re-computation block is removed.validate_sample_weightsis 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-featurespasses (554 unit tests + doctests),cargo clippy --all-features -- -Drust-2018-idioms -Drust-2024-compatibility -Dwarningsandcargo fmt --all -- --checkare clean.Change logs
Changed
tree:BaseTreeRegressor::find_best_cutofftakes the nodemassas a parameter. The root mass comes fromfit_weak_learner; child masses are accumulated insplitduring the sample partition. Internal API only.tree,ensemble:validate_sample_weightsis private to each of the three entry-point modules instead ofpub(crate)inbase_tree_regressor. Internal API only.