Fix positive raw scores for TreeEnsembleClassifier (#2824)

Fix positive raw scores for TreeEnsembleClassifier
This commit is contained in:
Xavier Dupré 2020-01-20 16:48:37 +01:00 committed by GitHub
parent b21576eeb0
commit 22d9f3998e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 9 deletions

View file

@ -322,6 +322,7 @@ void write_scores(std::vector<T>& 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<T>& 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;
}
}
}

View file

@ -78,7 +78,7 @@ TEST(MLOpTest, TreeEnsembleClassifierLabels) {
std::vector<std::string> results = {"label1", "label0", "label0", "label0", "label0", "label1", "label0", "label0"};
std::vector<float> probs = {};
std::vector<float> log_probs = {};
std::vector<float> scores{-5, 5, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -3, 3};
std::vector<float> 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;