remove weights_are_all_positive_ from TreeEnsemble#27552
Open
remove weights_are_all_positive_ from TreeEnsemble#27552
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a TreeEnsembleClassifier binary edge case where post_transform=LOGISTIC could incorrectly skip applying sigmoid when the model is a degenerate “leaf-only” tree with all non-negative weights, by removing the weights_are_all_positive_ heuristic from the TreeEnsemble implementation and adding a Python regression test.
Changes:
- Remove
weights_are_all_positive_fromTreeEnsembleCommonClassifierinitialization and fromTreeAggregatorClassifier. - Update binary-case scoring to always use the “logit-style” path (add_second_class = 2/3) so
LOGISTICis applied consistently. - Add a Python unit test covering split-tree, leaf-only, and leaf-only-with-negative-weight scenarios for
post_transform=LOGISTIC.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| onnxruntime/test/python/onnxruntime_test_python.py | Adds a regression test for issue #27533 validating sigmoid application in binary TreeEnsembleClassifier LOGISTIC mode, including leaf-only trees. |
| onnxruntime/core/providers/cpu/ml/tree_ensemble_common.h | Removes weights_are_all_positive_ tracking and simplifies binary-case detection via class-id set construction. |
| onnxruntime/core/providers/cpu/ml/tree_ensemble_aggregator.h | Removes the all-positive-weights branch and forces binary-case scoring to route through add_second_class 2/3 so LOGISTIC applies sigmoid. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…xadupre/tree27533
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.
Description
Remove weights_are_all_positive_. This attribute was part of the code because the post transform was originally shared with SVM. This is no longer the case.
Motivation and Context
Fixes #27533.