From 22d9f3998e36c40bbf502f8333bf62de383b2cbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xavier=20Dupr=C3=A9?= Date: Mon, 20 Jan 2020 16:48:37 +0100 Subject: [PATCH] Fix positive raw scores for TreeEnsembleClassifier (#2824) Fix positive raw scores for TreeEnsembleClassifier --- onnxruntime/core/providers/cpu/ml/ml_common.h | 9 +-------- .../providers/cpu/ml/tree_ensembler_classifier_test.cc | 2 +- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/onnxruntime/core/providers/cpu/ml/ml_common.h b/onnxruntime/core/providers/cpu/ml/ml_common.h index 618635edb5..6b46d818fc 100644 --- a/onnxruntime/core/providers/cpu/ml/ml_common.h +++ b/onnxruntime/core/providers/cpu/ml/ml_common.h @@ -322,6 +322,7 @@ void write_scores(std::vector& scores, POST_EVAL_TRANSFORM post_transform, in scores[0] = 1.f - scores[0]; break; case 2: //2 = mixed weights, winning class is positive + case 3: //3 = mixed weights, winning class is negative if (post_transform == POST_EVAL_TRANSFORM::LOGISTIC) { scores.push_back(ComputeLogistic(scores[0])); //ml_logit(scores[k]); scores[0] = ComputeLogistic(-scores[0]); @@ -330,14 +331,6 @@ void write_scores(std::vector& scores, POST_EVAL_TRANSFORM post_transform, in scores[0] = -scores[0]; } break; - case 3: //3 = mixed weights, winning class is negative - if (post_transform == POST_EVAL_TRANSFORM::LOGISTIC) { - scores.push_back(ComputeLogistic(scores[0])); //ml_logit(scores[k]); - scores[0] = ComputeLogistic(-scores[0]); - } else { - scores.push_back(-scores[0]); - } - break; } } } diff --git a/onnxruntime/test/providers/cpu/ml/tree_ensembler_classifier_test.cc b/onnxruntime/test/providers/cpu/ml/tree_ensembler_classifier_test.cc index 36318226ef..eb85f3d8e1 100644 --- a/onnxruntime/test/providers/cpu/ml/tree_ensembler_classifier_test.cc +++ b/onnxruntime/test/providers/cpu/ml/tree_ensembler_classifier_test.cc @@ -78,7 +78,7 @@ TEST(MLOpTest, TreeEnsembleClassifierLabels) { std::vector results = {"label1", "label0", "label0", "label0", "label0", "label1", "label0", "label0"}; std::vector probs = {}; std::vector log_probs = {}; - std::vector scores{-5, 5, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -3, 3}; + std::vector scores{-5, 5, 1, -1, 1, -1, 1, -1, 1, -1, -1, 1, 1, -1, 3, -3}; //define the context of the operator call const int N = 8;