Open
Description
When exporting a Booster model trained with the Logitraw objective function using m2cgen
, a sigmoid function is applied to the final score in the resulting C or Python code as if the Logistic objective function had been utilized during training.
#include <math.h>
static float sigmoid(float x) {
if (x < 0) {
float z = expf(x);
return z / (1.0f + z);
}
return 1.0f / (1.0f + expf(-x));
}
void predict(uint32_t* x, float* y) {
// [... boosting rounds omitted ...]
float v11 = sigmoid(v0 + v1 + v2 + v3 + v4 + v5 + v6 + v7 + v8 + v9 + v10);
memcpy(y, (float[]){1.0f - v11, v11}, 2 * sizeof(float));
}
In this snippet, the sigmoid()
function should not be applied on the final sum, since logitraw
uses the raw score output from single trees.
Anyone can confirm this?
Thanks
Metadata
Assignees
Labels
No labels
Activity