ITADN

Logitraw objective function ignored for xgb.Booster

#585OpenGuidoBartoli 创建于 2023-10-12
G
GuidoBartolicommented
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. Code with Logistic objective (C code): ``` #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 trees 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 should output the raw score. Anyone can confirm this? Thanks
0 条评论