SerAlejo
SerAlejo

Reputation: 493

LightGBM unexpected behaviour outside of jupyter

I have this strange but when I'm using a LightGBM model to calculate some predictions.

I trained a LightGBM model inside of jupyter and dumped it into a file using pickle. This model is used in an external class.

My problem is when I call my prediction function from this external class outside of jupyter it always predicts an output of 0.5 (on all rows). When I use the exact same class inside of jupyter I get the expected output. In both cases the exact same model is used with the exact same data.

How can this behavior be explained and how can I achieve to get the same results outside of jupyter? Has it something to do with the fact I trained the model inside of jupyter? (I can't imagine why it would, but atm have no clue where this bug is coming from)

Edit: Used versions: Both times the same lgb version is used (2.2.3), I also checked the python version which are equal (3.6.8) and all system paths (sys.path output). The paths are equal except of '/home/xxx/.local/lib/python3.6/site-packages/IPython/extensions' and '/home/xxx/.ipython'.

Edit 2: I copied the code I used inside of my jupyter and ran it as a normal python file. The model made this way works now inside of jupyter and outside of it. I still wonder why this bug accrued.

Upvotes: 0

Views: 190

Answers (1)

Simon Delecourt
Simon Delecourt

Reputation: 1599

It can't be a jupyter problem since jupyter is just an interface to communicate with python. The problem could be that you are using different python environment and different version of lgbm... Check import lightgbm as lgb and lgb.__version__ on both jupyter and your python terminal and make sure there are the same (or check if there has been some major changements between these versions)

Upvotes: 1

Related Questions