Skip to content

Graph lasso precision test failure on win-32/mkl/python3.7 #12175

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
amueller opened this issue Sep 26, 2018 · 3 comments
Open

Graph lasso precision test failure on win-32/mkl/python3.7 #12175

amueller opened this issue Sep 26, 2018 · 3 comments

Comments

@amueller
Copy link
Member

In def test_graph_lasso(random_state=0):

ContinuumIO/anaconda-issues#10112 (comment)

@adrinjalali
Copy link
Member

IIRC, passing 0 to make_sparse_spd_matrix instead of random_state may fix the issue (at least worked for me, amd still don't know why)!

@ogrisel
Copy link
Member

ogrisel commented Sep 27, 2018

The mismatch looks small enough. Maybe relaxing decimal=4 to decimal=3 would be fine.

@adrinjalali
Copy link
Member

Assume the following script, which is similar to the one giving the error, but up to generating the X:

import numpy as np
from scipy import linalg
from sklearn.datasets import make_sparse_spd_matrix

import platform; print(platform.platform())
import sys; print("Python", sys.version)
import numpy; print("NumPy", numpy.__version__)
import scipy; print("SciPy", scipy.__version__)
import sklearn; print("Scikit-Learn", sklearn.__version__)

n_samples = 60
n_features = 20
prng = np.random.RandomState(1)
prec = make_sparse_spd_matrix(n_features, alpha=.98,
                              smallest_coef=.4,
                              largest_coef=.7,
                              random_state=prng)
print(np.sum(prec))
cov = linalg.inv(prec)
d = np.sqrt(np.diag(cov))
cov /= d
cov /= d[:, np.newaxis]
print(np.sum(cov))
X = prng.multivariate_normal(np.zeros(n_features), cov, size=n_samples)
print(np.sum(X))

Now running on 3 different systems:

Linux-4.9.0-7-686-pae-i686-with-debian-9.5
Python 3.5.3 (default, Jan 19 2017, 14:11:04) 
[GCC 6.3.0 20170118]
NumPy 1.15.1
SciPy 1.1.0
Scikit-Learn 0.21.dev0
17.481835851333095
23.695085274246313
-20.307647445981004
Linux-3.16.0-4-amd64-x86_64-with-debian-8.11
Python 3.4.2 (default, Oct  8 2014, 10:45:20) 
[GCC 4.9.1]
NumPy 1.15.2
SciPy 1.1.0
Scikit-Learn 0.21.dev0
17.481835851333095
23.69508527424631
-23.416586673442204
Linux-4.14.72-1-lts-x86_64-with-arch
Python 3.7.0 (default, Sep 15 2018, 19:13:07) 
[GCC 8.2.1 20180831]
NumPy 1.15.1
SciPy 1.1.0
Scikit-Learn 0.21.dev0
17.481835851333095
23.69508527424631
-19.80669053466584

And now this script (not using prng in the call for make_sparse_spd_matrix):

import numpy as np
from scipy import linalg
from sklearn.datasets import make_sparse_spd_matrix

import platform; print(platform.platform())
import sys; print("Python", sys.version)
import numpy; print("NumPy", numpy.__version__)
import scipy; print("SciPy", scipy.__version__)
import sklearn; print("Scikit-Learn", sklearn.__version__)

n_samples = 60
n_features = 20
prng = np.random.RandomState(1)
prec = make_sparse_spd_matrix(n_features, alpha=.98,
                              smallest_coef=.4,
                              largest_coef=.7,
                              random_state=0)
print(np.sum(prec))
cov = linalg.inv(prec)
d = np.sqrt(np.diag(cov))
cov /= d
cov /= d[:, np.newaxis]
print(np.sum(cov))
X = prng.multivariate_normal(np.zeros(n_features), cov, size=n_samples)
print(np.sum(X))

And the same 3 different runs:

Linux-4.9.0-7-686-pae-i686-with-debian-9.5
Python 3.5.3 (default, Jan 19 2017, 14:11:04) 
[GCC 6.3.0 20170118]
NumPy 1.15.1
SciPy 1.1.0
Scikit-Learn 0.21.dev0
19.100114996975343
21.12867039681386
43.091071967881724
Linux-3.16.0-4-amd64-x86_64-with-debian-8.11
Python 3.4.2 (default, Oct  8 2014, 10:45:20) 
[GCC 4.9.1]
NumPy 1.15.2
SciPy 1.1.0
Scikit-Learn 0.21.dev0
19.100114996975343
21.12867039681386
36.11676941532882
Linux-4.14.72-1-lts-x86_64-with-arch
Python 3.7.0 (default, Sep 15 2018, 19:13:07) 
[GCC 8.2.1 20180831]
NumPy 1.15.1
SciPy 1.1.0
Scikit-Learn 0.21.dev0
19.100114996975343
21.12867039681386
36.11676941532882

The result for the 32bit is still different, but the 64bit ones become the same. I've been struggling with it working on PR #11732 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants