Skip to content

Fix TreeEnsembleRegressor to add base_values to final prediction. Round 2. #5569

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from

Conversation

corwinjoy
Copy link
Contributor

Description

In the reference implementation of TreeEnsembleRegressor when a value is provided for the base_values argument, this value replaces any prediction. This can't be what's intended and does not match onnxruntime. Instead, the base_value should be added to the prediction after applying any aggregation.

Motivation and Context

We are exporting regression trees into ONNX that have a non-zero base_value as the baseline prediction for the tree. Prediction works as expected in onnxruntime but not in the reference implementation. I believe this is an oversight and propose the fix (plus tests) below. I also think the documentation should be more explicit about what the base_values argument does.

…ate docs to clarify convention.

Signed-off-by: Corwin Joy <corwinjoy@gmail.com>
@corwinjoy corwinjoy requested review from a team as code owners September 6, 2023 04:06
@corwinjoy
Copy link
Contributor Author

corwinjoy commented Sep 6, 2023

Redo of the previous PR to cleanup commit history.

@xadupre xadupre enabled auto-merge September 6, 2023 04:08
@gramalingam
Copy link
Contributor

There are some CI failures. Looks like an erroneous opset version (4) problem? Maybe we need to specify the target opset version for the newly added tests (in the reference implementation)?

@xadupre
Copy link
Contributor

xadupre commented Sep 11, 2023

I did not have time to investigate. If we specify opset 4 for ai.onnx.ml it should pick the operator defined in opset 3. It looks like a bug.

@xadupre
Copy link
Contributor

xadupre commented Sep 15, 2023

This issue seems more complex. The tests are passing with the external protobuf but not with the internal version.

@xadupre
Copy link
Contributor

xadupre commented Oct 13, 2023

I proposed a fix in #5665, the only change is https://github.com/onnx/onnx/pull/5665/files#diff-d0acfbc52fc9a25dab6fb8f2057b06d2ccf075f37129c1fac460ca8564c55597R833: @parameterized decorator must be placed before @UnitTest one. #5665 can be checked in or merged into this one.

@corwinjoy
Copy link
Contributor Author

@xadupre Thanks for investigating! I couldn't tell why the tests were failing. I am happy to go with your updated PR!

@corwinjoy corwinjoy closed this Oct 14, 2023
auto-merge was automatically disabled October 14, 2023 01:53

Pull request was closed

github-merge-queue bot pushed a commit that referenced this pull request Oct 18, 2023
This PR fixes one line failing on #5569. What follows comes from this PR
description.

### Description

In the reference implementation of TreeEnsembleRegressor when a value is
provided for the base_values argument, this value replaces any
prediction. This can't be what's intended and does not match
onnxruntime. Instead, the base_value should be added to the prediction
after applying any aggregation.

### Motivation and Context

We are exporting regression trees into ONNX that have a non-zero
base_value as the baseline prediction for the tree. Prediction works as
expected in onnxruntime but not in the reference implementation. I
believe this is an oversight and propose the fix (plus tests) below. I
also think the documentation should be more explicit about what the
base_values argument does.

---------

Signed-off-by: Corwin Joy <corwinjoy@gmail.com>
Signed-off-by: Xavier Dupre <xadupre@microsoft.com>
Co-authored-by: Corwin Joy <corwin.joy@gmail.com>
Co-authored-by: G. Ramalingam <grama@microsoft.com>
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.

3 participants