{"action":"opened","issue":{"url":"https://api.github.com/repos/scipy/scipy/issues/8208","repository_url":"https://api.github.com/repos/scipy/scipy","labels_url":"https://api.github.com/repos/scipy/scipy/issues/8208/labels{/name}","comments_url":"https://api.github.com/repos/scipy/scipy/issues/8208/comments","events_url":"https://api.github.com/repos/scipy/scipy/issues/8208/events","html_url":"https://github.com/scipy/scipy/issues/8208","id":281082619,"number":8208,"title":"scipy.linalg.lstsq is sometimes not deterministic","user":{"login":"TomDLT","id":11065596,"avatar_url":"https://avatars2.githubusercontent.com/u/11065596?v=4","gravatar_id":"","url":"https://api.github.com/users/TomDLT","html_url":"https://github.com/TomDLT","followers_url":"https://api.github.com/users/TomDLT/followers","following_url":"https://api.github.com/users/TomDLT/following{/other_user}","gists_url":"https://api.github.com/users/TomDLT/gists{/gist_id}","starred_url":"https://api.github.com/users/TomDLT/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TomDLT/subscriptions","organizations_url":"https://api.github.com/users/TomDLT/orgs","repos_url":"https://api.github.com/users/TomDLT/repos","events_url":"https://api.github.com/users/TomDLT/events{/privacy}","received_events_url":"https://api.github.com/users/TomDLT/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-12-11T16:35:31Z","updated_at":"2017-12-11T16:35:31Z","closed_at":null,"author_association":"NONE","body":"`scipy.linalg.lstsq` is sometimes not deterministic, as shown by the following test:\r\n\r\n### Reproducing code example:\r\n\r\n```py\r\nfrom scipy.linalg import lstsq\r\nfrom sklearn.utils.testing import assert_array_equal\r\n# requires scikit-learn >= 0.19\r\nfrom sklearn.tests.test_multioutput import generate_multilabel_dataset_with_correlations\r\n\r\ndef test_investigate_linear_regression_indeterminacy():\r\n    # Is scipy.linalg.lstsq deterministic?\r\n    X, Y = generate_multilabel_dataset_with_correlations()\r\n    y = Y[:, 1].astype(np.float64)\r\n    X -= X.mean(axis=0)\r\n    y -= y.mean()\r\n\r\n    ref = lstsq(X, y)[0]\r\n    for i in range(1000):\r\n        coef = lstsq(X, y)[0]\r\n        assert_array_equal(ref, coef, 'iter %d' % i)\r\n\r\ntest_investigate_linear_regression_indeterminacy()\r\n```\r\n\r\nwhich failed at iteration 4 in [this Travis job](https://travis-ci.org/scikit-learn/scikit-learn/jobs/314836481). I can't reproduce locally.\r\nIt only occurs on one Travis platform (python 3.6.2), only sometimes (iteration 4 in this test case). \r\n\r\ncf. https://github.com/scikit-learn/scikit-learn/issues/10283\r\n\r\n### Error message:\r\n```pytb\r\n_______________ test_investigate_linear_regression_indeterminacy _______________\r\n    def test_investigate_linear_regression_indeterminacy():\r\n        # Is scipy.linalg.lstsq deterministic?\r\n        from scipy.linalg import lstsq\r\n        X, Y = generate_multilabel_dataset_with_correlations()\r\n        y = Y[:, 1].astype(np.float64)\r\n        X -= X.mean(axis=0)\r\n        y -= y.mean()\r\n    \r\n        ref = lstsq(X, y)[0]\r\n        for i in range(1000):\r\n            coef = lstsq(X, y)[0]\r\n>           assert_array_equal(ref, coef, 'iter %d' % i)\r\nE           AssertionError: \r\nE           Arrays are not equal\r\nE           iter 4\r\nE           (mismatch 100.0%)\r\nE            x: array([  7.186580e-03,  -9.998066e-03,   3.580353e-03,  -1.627024e-03,\r\nE                   -3.538778e-03,  -2.532519e-02,   1.074851e-03,   3.214291e-02,\r\nE                    1.339362e+11,  -1.486778e-03,   1.718521e-03,  -4.677074e+11,...\r\nE            y: array([  7.186536e-03,  -1.046430e-02,   3.667191e-03,  -1.917473e-03,\r\nE                   -3.596765e-03,  -2.608710e-02,   1.081140e-03,   3.199401e-02,\r\nE                    1.935733e+10,  -1.960874e-03,   1.906514e-03,  -5.467077e+11,...\r\nX          = array([[ 0.84669656, -1.204     ,  1.88065131, ..., -1.03091981,\r\n         0.23908269, -0.74727976],\r\n       [-1.7728545...453, -1.04129346],\r\n       [-1.07081749, -1.21883974, -1.25895606, ...,  0.9049708 ,\r\n        -1.04203549, -1.92876323]])\r\nY          = array([[0, 0, 1, 1],\r\n       [0, 1, 1, 0],\r\n       [1, 0, 1, 1],\r\n       ..., \r\n       [1, 1, 1, 0],\r\n       [0, 0, 1, 0],\r\n       [0, 1, 0, 0]])\r\ncoef       = array([  7.18653565e-03,  -1.04643041e-02,   3.66719062e-03,\r\n        -1.91747279e-03,  -3.59676502e-03,  -2.60871046e-....52494812e-02,  -1.96304321e-02,\r\n        -8.03375244e-03,  -1.19493604e-02,   8.68475437e-03,\r\n         8.89170170e-03])\r\ni          = 4\r\nlstsq      = <function lstsq at 0x7f3ea2ede9d8>\r\nref        = array([  7.18657983e-03,  -9.99806642e-03,   3.58035269e-03,\r\n        -1.62702376e-03,  -3.53877774e-03,  -2.53251890e-....51331329e-02,  -1.94740295e-02,\r\n        -8.06188583e-03,  -1.21812820e-02,   8.45718384e-03,\r\n         8.93211365e-03])\r\ny          = array([-0.504,  0.496, -0.504, -0.504, -0.504, -0.504,  0.496,  0.496,\r\n       -0.504, -0.504,  0.496, -0.504, -0.504, ... 0.496, -0.504, -0.504,  0.496,  0.496,  0.496,\r\n       -0.504,  0.496, -0.504, -0.504,  0.496,  0.496, -0.504,  0.496])\r\n/home/travis/build/scikit-learn/scikit-learn/sklearn/tests/test_multioutput.py:486: AssertionError\r\n====== 1 failed, 8351 passed, 26 skipped, 4860 warnings in 495.55 seconds ======\r\n```\r\n\r\n### Scipy/Numpy/Python version information:\r\n```py\r\n# Travis build versions\r\nSCIPY_VERSION=\"0.19.1\"\r\nNUMPY_VERSION=\"1.13.1\"\r\nPYTHON_VERSION=\"3.6.2\"\r\n```\r\n\r\n"}}
{"actor":{"display_login":"TomDLT"}}