-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Python gbm.feature_importance() error? #615
Comments
test both python 2 and 3, no error. try latest code |
Still has error. I have tried the latest code. Below is the complete error:
|
try set num_boost_round=1 to see if it works. btw, you should quote your error msg with ``` |
It works. But why does this happen? |
feature importances use a string buffer passed from c++ to python, I guess the string buffer for 250 rounds is too long and be cut during passing. |
Sorry. My OS is NOT Windows. It's linux. |
Oh, sorry, misread it. |
Strange I set num_boost_round to 1M and still cannot reproduce it. You can change this line to |
I did what you posted. But I can't
|
FYI, my data has 4.6 million rows and 220 columns. |
It's strange, json.loads already removed, why still show "No JSON object could be decoded"? I still try reproduce this issue, need some time. |
I rerun my code today. Error is different:
|
dump_model() seems work, can you try dump_model() again? |
Strange that model.json seems not been cut. Try this:
|
|
I think I find out the reason. Can you also save_model() and upload here? |
Thanks for your help. You can change this line https://github.com/Microsoft/LightGBM/blob/master/src/io/tree.cpp#L369 to |
@wxchan |
@guolinke add Common::AvoidInf to threshold_double? I will keep the change on L369, it helps when user loads old model. |
@wxchan yes and okay. |
@wxchan Thanks. it works. |
@vousmevoyez you can pip install simplejson, it's more efficient and has better error message. |
OK. |
This issue has been automatically locked since there has not been any recent activity since it was closed. To start a new related discussion, open a new issue at https://github.com/microsoft/LightGBM/issues including a reference to this. |
Environment info
Operating System: Linux
CPU:
Python version: Python 2.7.13
Error Message:
ValueError: No JSON object could be decoded
Reproducible examples
lgb_train = lgb.Dataset(X_train, y_train)
lgb_eval = lgb.Dataset(X_test, y_test, reference=lgb_train)
params = {
'task':'train',
'boosting':'gbdt',
'objective':'binary',
'metric':{'l2', 'auc'},
'num_leaves': 62,
'learning_rate': 0.05,
'feature_fraction': 0.9,
'bagging_fraction': 0.8,
'bagging_freq': 5,
'verbose': 20
}
gbm = lgb.train(params,
lgb_train,
num_boost_round=250,
valid_sets=lgb_eval)
print('Start predicting...')
y_pred = gbm.predict(X_test, num_iteration=gbm.best_iteration)
y_pred = np.round(y_pred)
print gbm.feature_importance()
The text was updated successfully, but these errors were encountered: