Skip to content

Conversation

@NinaHerrmann
Copy link

First of all thank you for the library, I really appreciate using it. I am not to familiar with python libraries so excuse me if I am missing something obvious.
Problem:
When generating XGBoost models I came across the error:

File “[…].venv/lib/python3.13/site-packages/m2cgen/assemblers/boosting.py", line 80, in _assemble_bin_class_output
    base_score = -math.log(1.0 / self._base_score - 1.0)
                           ~~~~^~~~~~~~~~~~~~~~~~
TypeError: unsupported operand type(s) for /: 'float' and 'NoneType'

XGBoost 2.0 New says:

In the previous version, base_score was a constant that could be set as a training parameter. In the new version, XGBoost can automatically estimate this parameter based on input labels for optimal accuracy. (#8539, #8498, #8272, #8793, #8607)

github

Proposed solution:

To be compatible I check for None in BaseBoostingAssembler and check the two different ways (model.get_params().get("base_score") and model.intercept_ is not None) in XGBoostTreeModelAssembler passing it to the super.

Related:
#587 #581

Thanks for your feedback!

…conditional checks for param base_score and intercept value for XGBoostTreeModelAssembler
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant