From 8fd69715a09b3f9582d8e1d41ebc446bb7dfd685 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xavier=20Dupr=C3=A9?= Date: Wed, 18 Oct 2023 23:44:08 +0200 Subject: [PATCH] TreeEnsemble base values for the reference implementation (#5665) 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 Signed-off-by: Xavier Dupre Co-authored-by: Corwin Joy Co-authored-by: G. Ramalingam --- docs/Changelog-ml.md | 4 +-- docs/Operators-ml.md | 4 +-- onnx/defs/traditionalml/defs.cc | 4 +-- .../aionnxml/op_tree_ensemble_regressor.py | 4 ++- onnx/test/reference_evaluator_ml_test.py | 33 +++++++++++++------ 5 files changed, 32 insertions(+), 17 deletions(-) diff --git a/docs/Changelog-ml.md b/docs/Changelog-ml.md index 1a84d5c0460..0beb74a5022 100644 --- a/docs/Changelog-ml.md +++ b/docs/Changelog-ml.md @@ -1085,9 +1085,9 @@ This version of the operator has been available since version 3 of the 'ai.onnx.
aggregate_function : string (default is SUM)
Defines how to aggregate leaf values within a target.
One of 'AVERAGE,' 'SUM,' 'MIN,' 'MAX.'
base_values : list of floats
-
Base values for classification, added to final class score; the size must be the same as the classes or can be left unassigned (assumed 0)
+
Base values for regression, added to final prediction after applying aggregate_function; the size must be the same as the classes or can be left unassigned (assumed 0)
base_values_as_tensor : tensor
-
Base values for classification, added to final class score; the size must be the same as the classes or can be left unassigned (assumed 0)
+
Base values for regression, added to final prediction after applying aggregate_function; the size must be the same as the classes or can be left unassigned (assumed 0)
n_targets : int
The total number of targets.
nodes_falsenodeids : list of ints
diff --git a/docs/Operators-ml.md b/docs/Operators-ml.md index 17f360d5b56..decdb54b316 100644 --- a/docs/Operators-ml.md +++ b/docs/Operators-ml.md @@ -1038,9 +1038,9 @@ Other versions of this operator: