From: Ricardo Wurmus <rekado@elephly.net>
To: 37433@debbugs.gnu.org
Cc: "Lindberg, Eric Lars-Helge" <Eric.Lindberg@mdc-berlin.de>
Subject: bug#37433: python-scikit-learn has two failing tests
Date: Tue, 17 Sep 2019 00:46:01 +0200 [thread overview]
Message-ID: <87ftkvq2qe.fsf@elephly.net> (raw)
The python-scikit-learn package fails to build due to two failing tests:
--8<---------------cut here---------------start------------->8---
=================================== FAILURES ===================================
___________________________ test_scale_and_stability ___________________________
def test_scale_and_stability():
# We test scale=True parameter
# This allows to check numerical stability over platforms as well
d = load_linnerud()
X1 = d.data
Y1 = d.target
# causes X[:, -1].std() to be zero
X1[:, -1] = 1.0
# From bug #2821
# Test with X2, T2 s.t. clf.x_score[:, 1] == 0, clf.y_score[:, 1] == 0
# This test robustness of algorithm when dealing with value close to 0
X2 = np.array([[0., 0., 1.],
[1., 0., 0.],
[2., 2., 2.],
[3., 5., 4.]])
Y2 = np.array([[0.1, -0.2],
[0.9, 1.1],
[6.2, 5.9],
[11.9, 12.3]])
for (X, Y) in [(X1, Y1), (X2, Y2)]:
X_std = X.std(axis=0, ddof=1)
X_std[X_std == 0] = 1
Y_std = Y.std(axis=0, ddof=1)
Y_std[Y_std == 0] = 1
X_s = (X - X.mean(axis=0)) / X_std
Y_s = (Y - Y.mean(axis=0)) / Y_std
for clf in [CCA(), pls_.PLSCanonical(), pls_.PLSRegression(),
pls_.PLSSVD()]:
clf.set_params(scale=True)
X_score, Y_score = clf.fit_transform(X, Y)
clf.set_params(scale=False)
X_s_score, Y_s_score = clf.fit_transform(X_s, Y_s)
assert_array_almost_equal(X_s_score, X_score)
assert_array_almost_equal(Y_s_score, Y_score)
# Scaling should be idempotent
clf.set_params(scale=True)
X_score, Y_score = clf.fit_transform(X_s, Y_s)
> assert_array_almost_equal(X_s_score, X_score)
E AssertionError:
E Arrays are not almost equal to 6 decimals
E
E (mismatch 50.0%)
E x: array([-1.337317, -0.041705, -1.108472, 0.098154, 0.407632, -0.103084,
E 2.038158, 0.046634])
E y: array([-1.337317, -0.041776, -1.108472, 0.0982 , 0.407632, -0.103027,
E 2.038158, 0.046602])
sklearn/cross_decomposition/tests/test_pls.py:365: AssertionError
____________________________ test_unsorted_indices _____________________________
def test_unsorted_indices():
# test that the result with sorted and unsorted indices in csr is the same
# we use a subset of digits as iris, blobs or make_classification didn't
# show the problem
digits = load_digits()
X, y = digits.data[:50], digits.target[:50]
X_test = sparse.csr_matrix(digits.data[50:100])
X_sparse = sparse.csr_matrix(X)
coef_dense = svm.SVC(kernel='linear', probability=True,
random_state=0).fit(X, y).coef_
sparse_svc = svm.SVC(kernel='linear', probability=True,
random_state=0).fit(X_sparse, y)
coef_sorted = sparse_svc.coef_
# make sure dense and sparse SVM give the same result
assert_array_almost_equal(coef_dense, coef_sorted.toarray())
X_sparse_unsorted = X_sparse[np.arange(X.shape[0])]
X_test_unsorted = X_test[np.arange(X_test.shape[0])]
# make sure we scramble the indices
> assert_false(X_sparse_unsorted.has_sorted_indices)
sklearn/svm/tests/test_sparse.py:118:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <sklearn.utils._unittest_backport.TestCase testMethod=__init__>, expr = 1
msg = '1 is not false'
def assertFalse(self, expr, msg=None):
"""Check that the expression is false."""
if expr:
msg = self._formatMessage(msg, "%s is not false" % safe_repr(expr))
> raise self.failureException(msg)
E AssertionError: 1 is not false
/gnu/store/b7fqhszxl02g6pfm3vw6b3cjz472qrly-python-3.7.0/lib/python3.7/unittest/case.py:686: AssertionError
[…]
2 failed, 10415 passed, 30 skipped, 1 deselected, 1 xfailed, 1026 warnings in 895.50 seconds
--8<---------------cut here---------------end--------------->8---
--
Ricardo
reply other threads:[~2019-09-16 22:47 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87ftkvq2qe.fsf@elephly.net \
--to=rekado@elephly.net \
--cc=37433@debbugs.gnu.org \
--cc=Eric.Lindberg@mdc-berlin.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).