Skip to content

ppc4le failure of test_pca_dtype_preservation #15774

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

Closed
jnothman opened this issue Dec 4, 2019 · 1 comment · Fixed by #15775
Closed

ppc4le failure of test_pca_dtype_preservation #15774

jnothman opened this issue Dec 4, 2019 · 1 comment · Fixed by #15775

Comments

@jnothman
Copy link
Member

jnothman commented Dec 4, 2019

From https://travis-ci.org/conda-forge/scikit-learn-feedstock/builds/620255817?utm_source=github_status&utm_medium=notification

______________________ test_pca_dtype_preservation[full] _______________________
svd_solver = 'full'
    @pytest.mark.parametrize('svd_solver', PCA_SOLVERS)
    def test_pca_dtype_preservation(svd_solver):
>       check_pca_float_dtype_preservation(svd_solver)
../_test_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_pla/lib/python3.6/site-packages/sklearn/decomposition/tests/test_pca.py:515: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
svd_solver = 'full'
    def check_pca_float_dtype_preservation(svd_solver):
        # Ensure that PCA does not upscale the dtype when input is float32
        X_64 = np.random.RandomState(0).rand(1000, 4).astype(np.float64,
                                                             copy=False)
        X_32 = X_64.astype(np.float32)
    
        pca_64 = PCA(n_components=3, svd_solver=svd_solver,
                     random_state=0).fit(X_64)
        pca_32 = PCA(n_components=3, svd_solver=svd_solver,
                     random_state=0).fit(X_32)
    
        assert pca_64.components_.dtype == np.float64
        assert pca_32.components_.dtype == np.float32
        assert pca_64.transform(X_64).dtype == np.float64
        assert pca_32.transform(X_32).dtype == np.float32
    
>       assert_allclose(pca_64.components_, pca_32.components_, rtol=1e-4)
E       AssertionError: 
E       Not equal to tolerance rtol=0.0001, atol=0
E       
E       Mismatch: 16.7%
E       Max absolute difference: 1.70156909e-05
E       Max relative difference: 0.00010702
E        x: array([[ 0.620224,  0.159835, -0.38317 , -0.66555 ],
E              [ 0.263179,  0.240851,  0.908007, -0.21966 ],
E              [-0.124977, -0.881087,  0.167274, -0.424366]])
E        y: array([[ 0.620221,  0.159831, -0.383173, -0.665551],
E              [ 0.263179,  0.240834,  0.908009, -0.219671],
E              [-0.124991, -0.881089,  0.167257, -0.424363]], dtype=float32)

cf. #12823

@thomasjpfan
Copy link
Member

I think we need to bump the tol to 2e-4. The components_ are obtained directly from linalg.svd here:

U, S, V = linalg.svd(X, full_matrices=False)
# flip eigenvectors' sign to enforce deterministic output
U, V = svd_flip(U, V)
components_ = V

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

Successfully merging a pull request may close this issue.

2 participants