Skip to content
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

JSONDecodeError: Expecting value when using lgb.plot_tree #2266

Closed
linuxTown opened this issue Jul 16, 2019 · 0 comments · Fixed by #2303
Closed

JSONDecodeError: Expecting value when using lgb.plot_tree #2266

linuxTown opened this issue Jul 16, 2019 · 0 comments · Fixed by #2303
Labels

Comments

@linuxTown
Copy link

linuxTown commented Jul 16, 2019

Issue

Hi, issue I am experiencing is very similar to issue in #1797. I can't use lgb.plot_tree as it always crashes on parsing JSON file. I have about 90 features, from which when I print out LightGBMRegressor feature_importance, about 50 are used in prediction making.

Environment info

Operating System: Ubuntu 18.04

LightGBM version: 2.2.3 installed via pip

Error message

This is the message I receive in logs:

....
  File "/usr/lib/python3/dist-packages/simplejson/decoder.py", line 370, in decode
    obj, end = self.raw_decode(s)
  File "/usr/lib/python3/dist-packages/simplejson/decoder.py", line 400, in raw_decode
    return self.scan_once(s, idx=_w(s, idx).end())
simplejson.errors.JSONDecodeError: Expecting value: line 26 column 14 (char 2057)

Somehow after fitting LightGBM generates invalid JSON file:

errorScreen

Why split_gain value is nan as it is invalid JSON value?

gbm = lgb.LGBMRegressor()
gbm_fitted = gbm.fit(X_train, y_train,
                         eval_set=[(X_val, y_val)],
                         eval_metric='rmse',
                         early_stopping_rounds=20, feature_name=column_names)
... plotting features, importances...
lgb.plot_tree(gbm_fitted) # <- this is where I receive error

Interesting part is that XGBoost plot_tree with same data after training is able to plot decision tree perfectly.

What could I do to make LGBM plot this tree?

@jameslamb jameslamb added the bug label Jul 17, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Mar 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants