question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

m2cgen output for xgboost with binary:logistic objective returns raw (not transformed) scores

See original GitHub issue

Our xgboost models use the binary:logistic' objective function, however the m2cgen converted version of the models return raw scores instead of the transformed scores.

This is fine as long as the user knows this is happening! I didn’t, so it took a while to figure out what was going on. I’m wondering if perhaps a useful warning could be raised for users to alert them of this issue? A warning could include a note that they can transform these scores back to the expected probabilities [0, 1] by prob = logistic.cdf(score - base_score) where base_score is an attribute of the xgboost model.

In our case, I’d like to minimize unnecessary processing on the device, so I am actually happy with the current m2cgen output and will instead inverse transform our threshold when evaluating the model output from the transpiled model…but it did take me a bit before I figured out what was going on, which is why I’m suggesting that a user friendly message might be raised when an unsupported objective function is encountered.

Thanks for creating & sharing this great tool!

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
izeigermancommented, Aug 28, 2019

@ehoppmann As a workaround you can just try passing the XGBClassifier instance instead of XGBRegressor one to ensure that a sigmoid is being applied in the generated code.

0reactions
HanLiiicommented, Dec 10, 2020

Our xgboost models use the binary:logistic' objective function, however the m2cgen converted version of the models return raw scores instead of the transformed scores.

This is fine as long as the user knows this is happening! I didn’t, so it took a while to figure out what was going on. I’m wondering if perhaps a useful warning could be raised for users to alert them of this issue? A warning could include a note that they can transform these scores back to the expected probabilities [0, 1] by prob = logistic.cdf(score - base_score) where base_score is an attribute of the xgboost model.

In our case, I’d like to minimize unnecessary processing on the device, so I am actually happy with the current m2cgen output and will instead inverse transform our threshold when evaluating the model output from the transpiled model…but it did take me a bit before I figured out what was going on, which is why I’m suggesting that a user friendly message might be raised when an unsupported objective function is encountered.

Thanks for creating & sharing this great tool!

hi,in the xgb2c code,what does output in the parameter of the function score mean and how can i get the predicted prob [0, 1] , thanks

Read more comments on GitHub >

github_iconTop Results From Across the Web

XGBoost Parameters — xgboost 1.7.2 documentation
Usually this parameter is not needed, but it might help in logistic regression ... for binary classification, output score before logistic transformation.
Read more >
What is the "binary:logistic" objective function in XGBoost?
“binary:logitraw” –logistic regression for binary classification, output score before logistic transformation.
Read more >
gbt_inference
e.g. for when building a binary classification, a logistic transformation will be needed on top of the raw prediction, whereas for the ...
Read more >
xgboost: Extreme Gradient Boosting
Use xgb.save.raw to save the XGBoost model as a sequence (vector) of ... eta = 1, nthread = 2, nrounds = 2, objective...
Read more >
XGBoost predictions output not binary? - python - Stack Overflow
Yes, it is the probability of getting 1. To get it as a binary value, just check whether it is greater or less...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found