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.

Unstable LogisticRegression with saga solver l1 penalty under macOS

See original GitHub issue
======================================================================
FAIL: sklearn.linear_model.tests.test_logistic.test_logreg_l1_sparse_data
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/travis/build/MacPython/scikit-learn-wheels/venv/lib/python3.6/site-packages/nose/case.py", line 198, in runTest
    self.test(*self.arg)
  File "/Users/travis/build/MacPython/scikit-learn-wheels/venv/lib/python3.6/site-packages/sklearn/linear_model/tests/test_logistic.py", line 961, in test_logreg_l1_sparse_data
    assert_array_almost_equal(lr_saga.coef_, lr_liblinear.coef_)
  File "/Users/travis/build/MacPython/scikit-learn-wheels/venv/lib/python3.6/site-packages/numpy/testing/utils.py", line 962, in assert_array_almost_equal
    precision=decimal)
  File "/Users/travis/build/MacPython/scikit-learn-wheels/venv/lib/python3.6/site-packages/numpy/testing/utils.py", line 778, in assert_array_compare
    raise AssertionError(msg)
AssertionError: 
Arrays are not almost equal to 6 decimals
(mismatch 64.0%)
 x: array([[ -128.209824,  -990.760917,     0.      ,     0.      ,
            0.      ,   783.90525 ,  1345.642841,     0.      ,
           34.880916,  -287.813868,  -364.684306,  -668.47532 ,...
 y: array([[-0.764085, -0.29863 ,  0.      ,  0.269297,  0.      ,  0.      ,
         2.629204,  0.      ,  0.      ,  0.      , -0.450364, -0.61554 ,
         0.      , -0.262512,  0.161514,  0.      ,  0.314769,  0.      ,...
======================================================================
FAIL: sklearn.linear_model.tests.test_logistic.test_saga_vs_liblinear
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/travis/build/MacPython/scikit-learn-wheels/venv/lib/python3.6/site-packages/nose/case.py", line 198, in runTest
    self.test(*self.arg)
  File "/Users/travis/build/MacPython/scikit-learn-wheels/venv/lib/python3.6/site-packages/sklearn/linear_model/tests/test_logistic.py", line 1144, in test_saga_vs_liblinear
    assert_array_almost_equal(saga.coef_, liblinear.coef_, 3)
  File "/Users/travis/build/MacPython/scikit-learn-wheels/venv/lib/python3.6/site-packages/numpy/testing/utils.py", line 962, in assert_array_almost_equal
    precision=decimal)
  File "/Users/travis/build/MacPython/scikit-learn-wheels/venv/lib/python3.6/site-packages/numpy/testing/utils.py", line 778, in assert_array_compare
    raise AssertionError(msg)
AssertionError: 
Arrays are not almost equal to 3 decimals
(mismatch 100.0%)
 x: array([[ -105.601, -1199.326,  2377.574,   479.408]])
 y: array([[ 0.   , -1.06 ,  1.222,  0.   ]])

numpy and scipy are imported from the following wheels from PyPI:

  • numpy-1.11.3-cp36-cp36m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (at buil time)

  • numpy-1.13.1-cp36-cp36m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (at test time)

  • scipy-0.19.1-cp36-cp36m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl

  • Cython-0.25.2-cp36-cp36m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl

The full log of the build is here:

https://s3.amazonaws.com/archive.travis-ci.org/jobs/253231280/log.txt?X-Amz-Expires=30&X-Amz-Date=20170713T160513Z&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAJRYRXRSVGNKPKO5A/20170713/us-east-1/s3/aws4_request&X-Amz-SignedHeaders=host&X-Amz-Signature=06e6866cac7abfc10cc67aa061a0e45b8db234c71a5997c67d8cc63828838df2

The configuration scripts of this build and test run can be found here:

https://github.com/MacPython/scikit-learn-wheels

A similar problem happened with Python 2.7 on macOS:

https://travis-ci.org/MacPython/scikit-learn-wheels/jobs/253231277

but not with python 3.4 for some reason:

https://travis-ci.org/MacPython/scikit-learn-wheels/builds/253231260

The same tests pass under Linux and Windows both 64 and 32 bit for all supported versions of Python.

Maybe this is a problem caused by the Apple Accelerate implementation of BLAS.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:15 (15 by maintainers)

github_iconTop GitHub Comments

2reactions
jnothmancommented, Jul 16, 2017

I woke up this morning realising why boundscheck wouldn’t work. It’s a pointer, not an array.

0reactions
jnothmancommented, Jul 16, 2017

Should Cython have found this for me if I set boundscheck=True? It didn’t, but maybe that’s just because it was failing to raise the exception with the gil off. Should we be regularly running all our Cython tests with boundscheck enabled and gil fixed to on?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using sklearn's LogisticRegression with 'saga' solver and ...
But now my code throws an error that I don't know how to resolve? Code: LR = LogisticRegression(random_state=1, solver='saga', penalty=' ...
Read more >
L1 Penalty and Sparsity in Logistic Regression - Scikit-learn
In the L1 penalty case, this leads to sparser solutions. As expected, the Elastic-Net penalty sparsity is between that of L1 and L2....
Read more >
scikit-learn user guide
NotImplementedError with 'l1' or 'l2' norm and with norm 'max' the norms ... LogisticRegression, the SAG solver is now available in the ...
Read more >
Problem formulations and solvers in linear SVM: a review
denotes Euclidean norm, 1 denotes a unit vector of arbitrary dimension and α denotes vector of dual variables. 2 Literature. Support vector machines...
Read more >
[scikit-learn] logistic regression results are not stable between ...
How can I check the objective of the l-bfgs and liblinear solvers with ... by using l1 penalty which is not supported >>>>>...
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