Skip to content

remove weights_are_all_positive_ from TreeEnsemble#27552

Open
xadupre wants to merge 6 commits intomainfrom
xadupre/tree27533
Open

remove weights_are_all_positive_ from TreeEnsemble#27552
xadupre wants to merge 6 commits intomainfrom
xadupre/tree27533

Conversation

@xadupre
Copy link
Member

@xadupre xadupre commented Mar 4, 2026

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.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can commit the suggested changes from lintrunner.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_ from TreeEnsembleCommonClassifier initialization and from TreeAggregatorClassifier.
  • Update binary-case scoring to always use the “logit-style” path (add_second_class = 2/3) so LOGISTIC is 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.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can commit the suggested changes from lintrunner.

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.

TreeEnsembleClassifier with post_transform=LOGISTIC skips sigmoid for leaf-only trees when all weights are non-negative

2 participants