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.

Code generated from XGBoost model includes "None"

See original GitHub issue

When transpiling XGBRegressor and XGBClassifier models such as the following basic example:

from xgboost import XGBRegressor
from sklearn import datasets
import m2cgen as m2c

iris_data = datasets.load_iris(return_X_y=True)

mod = XGBRegressor(booster="gblinear", max_depth=2)
X, y = iris_data
mod.fit(X[:120], y[:120])

code = m2c.export_to_c(mod)

print(code)

the resulting c-code includes a Pythonesque None :

double score(double * input) {
    return (None) + (((((-0.391196) + ((input[0]) * (-0.0196191))) + ((input[1]) * (-0.11313))) + ((input[2]) * (0.137024))) + ((input[3]) * (0.645197)));
}

Probably I am missing some basic step?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
izeigermancommented, Apr 7, 2020

@robinvanemden the issue has been fixed in version 0.7.0. Please feel free to reopen this issue if you notice it again.

2reactions
StrikerRUScommented, Mar 22, 2020

OK, they suggest using get_params() method to get actual values of parameters. Refer to https://github.com/dmlc/xgboost/blob/cfae247231e4977a78b255810565369c934fe1b5/tests/python/test_with_sklearn.py#L535-L537 I’ve created a PR with updates: #185.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python API Reference — xgboost 1.7.2 documentation
None. Example. import xgboost as xgb # Show all messages, including ones ... warning caused by model generated with XGBoost version < 1.0.0...
Read more >
How to Develop Your First XGBoost Model in Python
The XGBoost model for classification is called XGBClassifier. We can create and and fit it to our training dataset. Models are fit using...
Read more >
XGboost python package gives feature names as none
I am using pickle to load xgboost model. ... This was working perfectly fine, however suddenly started throwing this error. ... I encountered...
Read more >
Extensive hyperparameter tuning yields nothing, XGBoost ...
XGBoost is not the only machine learning model, ... Check your code for bugs, if there are no changes, maybe you are doing...
Read more >
Using XGBoost in Python Tutorial - DataCamp
Wide variety of tuning parameters : XGBoost internally has parameters for ... The tree ensemble model is a set of classification and regression...
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