Median branch assignment - #41
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.
Summary
Speeds up AbsoluteError (median / MAE) branch assignment during coordinate descent by replacing full partition re-sorts with dynamic structures.
Previously, AbsoluteError branch assignment either skipped CD or re-sorted each partition’s samples on every bin move (
O(n log n)per trial). This PR keeps sorted structure across leave/join so moves cost closer toO(n)orO(k log n).Algorithmic approaches
Merge/filter (default, production)
(y, w)array.(y, w)array plus source-bin ids.O(n + k).O(n).BST (deprecated, A/B)
WeightedMAETree) per partition/output with subtree(Σw, Σw·y).O(k log N); median/MAE —O(log N).Sort (deprecated, reference)
std::sorton every add/remove —O(n log n).Backends are hot-swappable via
SGTLEARN_MAE_BACKEND=merge|bst|sort. MAE CD remains gated bySGTLEARN_MAE_CD(off by default for sklearn CART parity). Implementations are split into separate files:AbsoluteErrorBranchAssignment(merge),…Bst,…Sort, plus shared helpers.Benchmarks
Timing scripts and CSVs are kept out of this PR and live on the fork:
josh-lee-MIE2t5/sgtlearn-MAE-CD-SpeedUp @
median-branch-assignmentSGTRegressor(absolute_error), MAE CD on,tao_n_runs=0CD-only (branch assignment)
Objectives matched across backends.
End-to-end shape-tree fit (median predictor)
Leaf counts identical across backends. Merge wins end-to-end fit; BST wins the CD-only microbench.