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.

Completely different output to original LGBMClassifier predict() and predict_proba() results

See original GitHub issue

Hi! I got completely different outputs for LGBMClassifier and “hummingbirded” model. It’s just tabular data with binary label.

Converted RandomForestClassifier works well on this data but it’s something wrong with lightgbm.

I tested hummingbird with lightgbm 3.2.1 and 2.1.1 version, results are the same. Outputs are completely different.

lgb_clf = lgb.LGBMClassifier()
lgb_clf.fit(X_train, y_train, eval_set=(X_test, y_test), verbose=10)

lgb_torch_model = convert(lgb_clf, 'pytorch')

lgb_clf.predict_proba(X_test)
>>
array([[0.0086527 , 0.9913473 ],
       [0.08489025, 0.91510975],
       [0.68027591, 0.31972409],
       ...,
       [0.14574664, 0.85425336],
       [0.35519048, 0.64480952],
       [0.149126  , 0.850874  ]])

lgb_torch_model.predict_proba(X_test)
>>
array([[0.6863004 , 0.31369957],
       [0.07888329, 0.9211167 ],
       [0.6015551 , 0.39844486],
       ...,
       [0.4556961 , 0.5443039 ],
       [0.5472065 , 0.45279348],
       [0.91947085, 0.08052915]], dtype=float32)


y_pred_lgb = lgb_clf.predict(X_test)
accuracy_score(y_test, y_pred_lgb)
>>
0.9557038067535095

y_pred_hmb = lgb_torch_model.predict(X_test)
accuracy_score(y_test, y_pred_hmb)
>>
0.6634469457442772

Python 3.9.5 OS: MacOS Big Sur 11.4

My environment:

# packages in environment at /opt/miniconda3/envs/hmb:
#
# Name                    Version                   Build  Channel
anyio                     3.2.1            py39h6e9494a_0    conda-forge
appnope                   0.1.2            py39h6e9494a_1    conda-forge
argon2-cffi               20.1.0           py39hcbf5805_2    conda-forge
async_generator           1.10                       py_0    conda-forge
attrs                     21.2.0             pyhd8ed1ab_0    conda-forge
babel                     2.9.1              pyh44b312d_0    conda-forge
backcall                  0.2.0              pyh9f0ad1d_0    conda-forge
backports                 1.0                        py_2    conda-forge
backports.functools_lru_cache 1.6.4              pyhd8ed1ab_0    conda-forge
bleach                    3.3.0              pyh44b312d_0    conda-forge
brotlipy                  0.7.0           py39hcbf5805_1001    conda-forge
ca-certificates           2021.5.30            h033912b_0    conda-forge
certifi                   2021.5.30        py39h6e9494a_0    conda-forge
cffi                      1.14.5           py39h319c39b_0    conda-forge
chardet                   4.0.0            py39h6e9494a_1    conda-forge
click                     8.0.1            py39h6e9494a_0    conda-forge
cramjam                   2.3.1            py39hce574ba_1    conda-forge
cryptography              3.4.7            py39ha2c9959_0    conda-forge
cycler                    0.10.0                     py_2    conda-forge
dbus                      1.13.6               ha13b53f_2    conda-forge
decorator                 5.0.9              pyhd8ed1ab_0    conda-forge
defusedxml                0.7.1              pyhd8ed1ab_0    conda-forge
dill                      0.3.4              pyhd8ed1ab_0    conda-forge
entrypoints               0.3             pyhd8ed1ab_1003    conda-forge
expat                     2.4.1                he49afe7_0    conda-forge
fastparquet               0.6.3            py39hc89836e_0    conda-forge
freetype                  2.10.4               h4cff582_1    conda-forge
fsspec                    2021.6.1           pyhd8ed1ab_0    conda-forge
future                    0.18.2           py39h6e9494a_3    conda-forge
gensim                    4.0.1            py39h9fcab8e_0    conda-forge
gettext                   0.19.8.1          h7937167_1005    conda-forge
glib                      2.68.3               he49afe7_0    conda-forge
glib-tools                2.68.3               he49afe7_0    conda-forge
hummingbird-ml            0.4.0              pyhd8ed1ab_0    conda-forge
icu                       68.1                 h74dc148_0    conda-forge
idna                      2.10               pyh9f0ad1d_0    conda-forge
importlib-metadata        4.5.0            py39h6e9494a_0    conda-forge
ipykernel                 5.5.5            py39h71a6800_0    conda-forge
ipython                   7.24.1           py39h71a6800_0    conda-forge
ipython_genutils          0.2.0                      py_1    conda-forge
ipywidgets                7.6.3              pyhd3deb0d_0    conda-forge
jbig                      2.1               h0d85af4_2003    conda-forge
jedi                      0.18.0           py39h6e9494a_2    conda-forge
jinja2                    3.0.1              pyhd8ed1ab_0    conda-forge
joblib                    1.0.1              pyhd8ed1ab_0    conda-forge
jpeg                      9d                   hbcb3906_0    conda-forge
json5                     0.9.5              pyh9f0ad1d_0    conda-forge
jsonschema                3.2.0              pyhd8ed1ab_3    conda-forge
jupyter                   1.0.0            py39h6e9494a_6    conda-forge
jupyter_client            6.1.12             pyhd8ed1ab_0    conda-forge
jupyter_console           6.4.0              pyhd8ed1ab_0    conda-forge
jupyter_core              4.7.1            py39h6e9494a_0    conda-forge
jupyter_server            1.9.0              pyhd8ed1ab_0    conda-forge
jupyterlab                3.0.16             pyhd8ed1ab_0    conda-forge
jupyterlab_pygments       0.1.2              pyh9f0ad1d_0    conda-forge
jupyterlab_server         2.6.0              pyhd8ed1ab_0    conda-forge
jupyterlab_widgets        1.0.0              pyhd8ed1ab_1    conda-forge
kiwisolver                1.3.1            py39hedf5dff_1    conda-forge
krb5                      1.19.1               hcfbf3a7_0    conda-forge
lcms2                     2.12                 h577c468_0    conda-forge
lerc                      2.2.1                h046ec9c_0    conda-forge
libblas                   3.9.0                     8_mkl    conda-forge
libcblas                  3.9.0                     8_mkl    conda-forge
libclang                  11.1.0          default_he082bbe_1    conda-forge
libcxx                    11.1.0               habf9029_0    conda-forge
libdeflate                1.7                  h35c211d_5    conda-forge
libedit                   3.1.20191231         h0678c8f_2    conda-forge
libffi                    3.3                  h046ec9c_2    conda-forge
libgfortran               5.0.0           9_3_0_h6c81a4c_22    conda-forge
libgfortran5              9.3.0               h6c81a4c_22    conda-forge
libglib                   2.68.3               hd556434_0    conda-forge
libiconv                  1.16                 haf1e3a3_0    conda-forge
liblapack                 3.9.0                     8_mkl    conda-forge
libllvm11                 11.1.0               hd011deb_2    conda-forge
libpng                    1.6.37               h7cec526_2    conda-forge
libpq                     13.3                 hea3049e_0    conda-forge
libprotobuf               3.15.8               hcf210ce_0    conda-forge
libsodium                 1.0.18               hbcb3906_1    conda-forge
libtiff                   4.3.0                h1167814_1    conda-forge
libwebp-base              1.2.0                h0d85af4_2    conda-forge
lightgbm                  3.2.1                    pypi_0    pypi
llvm-openmp               11.1.0               hda6cdc1_1    conda-forge
lz4-c                     1.9.3                h046ec9c_0    conda-forge
markupsafe                2.0.1            py39h89e85a6_0    conda-forge
matplotlib                3.4.2            py39h6e9494a_0    conda-forge
matplotlib-base           3.4.2            py39hb07454d_0    conda-forge
matplotlib-inline         0.1.2              pyhd8ed1ab_2    conda-forge
mistune                   0.8.4           py39hcbf5805_1003    conda-forge
mkl                       2020.4             h08c4f10_301    conda-forge
mysql-common              8.0.25               h694c41f_2    conda-forge
mysql-libs                8.0.25               h115446f_2    conda-forge
nbclassic                 0.3.1              pyhd8ed1ab_1    conda-forge
nbclient                  0.5.3              pyhd8ed1ab_0    conda-forge
nbconvert                 6.1.0            py39h6e9494a_0    conda-forge
nbformat                  5.1.3              pyhd8ed1ab_0    conda-forge
ncurses                   6.2                  h2e338ed_4    conda-forge
nest-asyncio              1.5.1              pyhd8ed1ab_0    conda-forge
ninja                     1.10.2               h9a9d8cb_0    conda-forge
nltk                      3.6.2              pyhd8ed1ab_0    conda-forge
notebook                  6.4.0              pyha770c72_0    conda-forge
nspr                      4.30                 hcd9eead_0    conda-forge
nss                       3.67                 h31e2bf1_0    conda-forge
numpy                     1.21.0           py39h7eed0ac_0    conda-forge
olefile                   0.46               pyh9f0ad1d_1    conda-forge
onnx                      1.9.0            py39hf443199_0    conda-forge
onnxconverter-common      1.8.1              pyhd8ed1ab_0    conda-forge
openjpeg                  2.4.0                h6e7aa92_1    conda-forge
openssl                   1.1.1k               h0d85af4_0    conda-forge
packaging                 20.9               pyh44b312d_0    conda-forge
pandas                    1.2.5            py39h4d6be9b_0    conda-forge
pandoc                    2.14.0.3             h0d85af4_0    conda-forge
pandocfilters             1.4.2                      py_1    conda-forge
parso                     0.8.2              pyhd8ed1ab_0    conda-forge
patsy                     0.5.1                      py_0    conda-forge
pcre                      8.45                 he49afe7_0    conda-forge
pexpect                   4.8.0              pyh9f0ad1d_2    conda-forge
pickleshare               0.7.5                   py_1003    conda-forge
pillow                    8.2.0            py39h5fdd921_1    conda-forge
pip                       21.1.2             pyhd8ed1ab_0    conda-forge
prometheus_client         0.11.0             pyhd8ed1ab_0    conda-forge
prompt-toolkit            3.0.19             pyha770c72_0    conda-forge
prompt_toolkit            3.0.19               hd8ed1ab_0    conda-forge
protobuf                  3.15.8           py39h9fcab8e_0    conda-forge
psutil                    5.8.0            py39h89e85a6_1    conda-forge
ptyprocess                0.7.0              pyhd3deb0d_0    conda-forge
pycparser                 2.20               pyh9f0ad1d_2    conda-forge
pygments                  2.9.0              pyhd8ed1ab_0    conda-forge
pyopenssl                 20.0.1             pyhd8ed1ab_0    conda-forge
pyparsing                 2.4.7              pyh9f0ad1d_0    conda-forge
pyqt                      5.12.3           py39h6e9494a_7    conda-forge
pyqt-impl                 5.12.3           py39hef7122c_7    conda-forge
pyqt5-sip                 4.19.18          py39hd8f94c5_7    conda-forge
pyqtchart                 5.12             py39hef7122c_7    conda-forge
pyqtwebengine             5.12.1           py39hef7122c_7    conda-forge
pyrsistent                0.17.3           py39hcbf5805_2    conda-forge
pysocks                   1.7.1            py39h6e9494a_3    conda-forge
python                    3.9.5           hd187cdc_0_cpython    conda-forge
python-dateutil           2.8.1                      py_0    conda-forge
python_abi                3.9                      2_cp39    conda-forge
pytorch                   1.8.0           cpu_py39h4f2e8f6_1    conda-forge
pytz                      2021.1             pyhd8ed1ab_0    conda-forge
pyzmq                     22.1.0           py39h7fec2f1_0    conda-forge
qt                        5.12.9               h126340a_4    conda-forge
qtconsole                 5.1.0              pyhd8ed1ab_0    conda-forge
qtpy                      1.9.0                      py_0    conda-forge
readline                  8.1                  h05e3726_0    conda-forge
regex                     2021.4.4         py39h89e85a6_0    conda-forge
requests                  2.25.1             pyhd3deb0d_0    conda-forge
requests-unixsocket       0.2.0                      py_0    conda-forge
scikit-learn              0.24.2           py39h4b1dcc9_0    conda-forge
scipy                     1.6.3            py39h056f1c0_0    conda-forge
seaborn                   0.11.1               hd8ed1ab_1    conda-forge
seaborn-base              0.11.1             pyhd8ed1ab_1    conda-forge
send2trash                1.7.1              pyhd8ed1ab_0    conda-forge
setuptools                49.6.0           py39h6e9494a_3    conda-forge
six                       1.16.0             pyh6c4a22f_0    conda-forge
sleef                     3.5.1                h35c211d_1    conda-forge
smart_open                5.1.0              pyhd8ed1ab_1    conda-forge
sniffio                   1.2.0            py39h6e9494a_1    conda-forge
sqlite                    3.36.0               h23a322b_0    conda-forge
statsmodels               0.12.2           py39h329c335_0    conda-forge
terminado                 0.10.1           py39h6e9494a_0    conda-forge
testpath                  0.5.0              pyhd8ed1ab_0    conda-forge
threadpoolctl             2.1.0              pyh5ca1d4c_0    conda-forge
thrift                    0.13.0           py39h9fcab8e_2    conda-forge
tk                        8.6.10               h0419947_1    conda-forge
tornado                   6.1              py39hcbf5805_1    conda-forge
tqdm                      4.61.1             pyhd8ed1ab_0    conda-forge
traitlets                 5.0.5                      py_0    conda-forge
typing-extensions         3.10.0.0             hd8ed1ab_0    conda-forge
typing_extensions         3.10.0.0           pyha770c72_0    conda-forge
tzdata                    2021a                he74cb21_0    conda-forge
urllib3                   1.26.5             pyhd8ed1ab_0    conda-forge
wcwidth                   0.2.5              pyh9f0ad1d_2    conda-forge
webencodings              0.5.1                      py_1    conda-forge
websocket-client          0.57.0           py39h6e9494a_4    conda-forge
wheel                     0.36.2             pyhd3deb0d_0    conda-forge
widgetsnbextension        3.5.1            py39h6e9494a_4    conda-forge
xz                        5.2.5                haf1e3a3_1    conda-forge
zeromq                    4.3.4                h1c7c35f_0    conda-forge
zipp                      3.4.1              pyhd8ed1ab_0    conda-forge
zlib                      1.2.11            h7795811_1010    conda-forge
zstd                      1.5.0                h582d3a0_0    conda-forge

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
alexyar88commented, Jun 25, 2021

I think no but I re-check it one more time and post results here

0reactions
alexyar88commented, Jun 28, 2021

@interesaaat the reason of this behaviour was int columns in my dataset. I just convert this columns to np.float32 and everything works fine. Thanks for helping me!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How does the predict_proba() function in LightGBM work ...
First, the predict_proba() method of the class LGBMClassifier is calling the predict() method from LGBMModel (it inherits from it).
Read more >
Different handling of similar looking data in LGBMClassifier ...
Look like if you use 1 * 4 numpy array, the problem remains: clf.predict_proba(np.array([list(X[1])])) . The issue is not checking predict input ...
Read more >
lightgbm.LGBMClassifier — LightGBM 3.3.3.99 documentation
(for multi-class task) The predicted values. Predicted values are returned before any transformation, e.g. they are raw margin instead of ...
Read more >
What is the difference between predict and predict_proba?
Hi! Consider a binary classification for labels 0 and 1. Predict will give either 0 or 1 as output. Predict_proba will give the...
Read more >
Calibration of probabilities for tree-based models
Let us get validation predictions from a lightgbm model. ... Our model shows an AUC of 0.784, which is a nice result in...
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