scikit-learn-contrib / lightning

Large-scale linear classification, regression and ranking in Python
https://contrib.scikit-learn.org/lightning/
1.73k stars 214 forks source link

Overflow in log loss function (use scipy.special.expit instead) #121

Closed aldanor closed 6 years ago

aldanor commented 6 years ago

This often pops up when using log loss function:

.../lightning/impl/base.py:55: RuntimeWarning: overflow encountered in exp
  prob = 1.0 / (1.0 + np.exp(-df))

which is to be expected; e.g., the following will cause this warning:

>>> 1 / (1 + np.exp(1000))

Instead, scipy.special.expit can be used which is more robust and doesn't suffer from overflow problems.

mblondel commented 6 years ago

Pull-request welcome :)

aldanor commented 6 years ago

@mblondel Done in #122 - would it be possible to release a 0.5.1 + conda packages if/when this gets merged?

mblondel commented 6 years ago

Thanks for the fix, closing.

@fabianp is taking care of releases but he might be busy lately.

fabianp commented 6 years ago

There are issues with the conda package: https://github.com/conda-forge/sklearn-contrib-lightning-feedstock/pull/5

Help is appreciated