Code Monkey home page Code Monkey logo

Comments (6)

DonnieFy avatar DonnieFy commented on May 27, 2024 1

meet the same error

from m2cgen.

GuidoBartoli avatar GuidoBartoli commented on May 27, 2024 1

Debugging into m2cgen code, maybe I managed to find a workaround for my case (export a native Booster to C and Python code), but I do not know if it works for other cases.

If the base_score parameter of the classifier is forced to 0 (the default value in the latest version is None), the check is passed and both Python and C code are generated.

# booster is already trained
temp_file = "temp.ubj"
booster.save_model(temp_file)
xgbclf = xgb.XGBClassifier()
xgbclf.load_model(temp_file)
os.remove(temp_file)
xgbclf.base_score = 0  # workaround
c_code = m2c.export_to_c(xgbclf)
py_code = m2c.export_to_python(xgbclf)

from m2cgen.

BennyH26 avatar BennyH26 commented on May 27, 2024

Encountering the same error. This is a breaking change for my pipeline. Any ideas here?

from m2cgen.

GuidoBartoli avatar GuidoBartoli commented on May 27, 2024

Encountering the same error. This is a breaking change for my pipeline. Any ideas here?

Yep, it is breaking for me too, I hope for some updates from the developer...

from m2cgen.

GuidoBartoli avatar GuidoBartoli commented on May 27, 2024

Taking a look at m2cgen/assemblers/boosting.py (line 78:80), I think the problem depends on self._base_score being None for some reason in the latest XGBoost model version, so the check if self._base_score != 0.0 is passed and the next instruction fails base_score = -math.log(1.0 / self._base_score - 1.0).

Maybe this model field has been renamed or removed, I will check it out and update this issue.

from m2cgen.

wyitong avatar wyitong commented on May 27, 2024

Debugging into m2cgen code, maybe I managed to find a workaround for my case (export a native Booster to C and Python code), but I do not know if it works for other cases.

If the base_score parameter of the classifier is forced to 0 (the default value in the latest version is None), the check is passed and both Python and C code are generated.

# booster is already trained
temp_file = "temp.ubj"
booster.save_model(temp_file)
xgbclf = xgb.XGBClassifier()
xgbclf.load_model(temp_file)
os.remove(temp_file)
xgbclf.base_score = 0  # workaround
c_code = m2c.export_to_c(xgbclf)
py_code = m2c.export_to_python(xgbclf)

This works for me. Thanks!

from m2cgen.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.