Repository navigation
Closed
Labels
BlockerBugModerateAnything that requires some knowledge of conventions and best practiceshelp wanted
Description
It seems that test_dtype_match has recently starte to fail on windows / appveyor builds:
def test_dtype_match():
# Test that np.float32 input data is not cast to np.float64 when possible
X_32 = np.array(X).astype(np.float32)
y_32 = np.array(Y1).astype(np.float32)
X_64 = np.array(X).astype(np.float64)
y_64 = np.array(Y1).astype(np.float64)
X_sparse_32 = sp.csr_matrix(X, dtype=np.float32)
for solver in ['newton-cg']:
for multi_class in ['ovr', 'multinomial']:
# Check type consistency
lr_32 = LogisticRegression(solver=solver, multi_class=multi_class)
lr_32.fit(X_32, y_32)
assert_equal(lr_32.coef_.dtype, X_32.dtype)
# check consistency with sparsity
lr_32_sparse = LogisticRegression(solver=solver,
multi_class=multi_class)
lr_32_sparse.fit(X_sparse_32, y_32)
assert_equal(lr_32_sparse.coef_.dtype, X_sparse_32.dtype)
# Check accuracy consistency
lr_64 = LogisticRegression(solver=solver, multi_class=multi_class)
lr_64.fit(X_64, y_64)
assert_equal(lr_64.coef_.dtype, X_64.dtype)
> assert_almost_equal(lr_32.coef_, lr_64.coef_.astype(np.float32))
E AssertionError:
E Arrays are not almost equal to 7 decimals
E
E (mismatch 100.0%)
E x: array([[0.6324632, 0.4584147]], dtype=float32)
E y: array([[0.6325136, 0.4583441]], dtype=float32)
X_32 = array([[-1., 0.],
[ 0., 1.],
[ 1., 1.]], dtype=float32)
X_64 = array([[-1., 0.],
[ 0., 1.],
[ 1., 1.]])
X_sparse_32 = <3x2 sparse matrix of type '<class 'numpy.float32'>'
with 4 stored elements in Compressed Sparse Row format>
lr_32 = LogisticRegression(C=1.0, class_weight=None, dual=False, fit_intercept=True,
intercept_scaling=1, max_iter=1...bs=1,
penalty='l2', random_state=None, solver='newton-cg', tol=0.0001,
verbose=0, warm_start=False)
lr_32_sparse = LogisticRegression(C=1.0, class_weight=None, dual=False, fit_intercept=True,
intercept_scaling=1, max_iter=1...bs=1,
penalty='l2', random_state=None, solver='newton-cg', tol=0.0001,
verbose=0, warm_start=False)
lr_64 = LogisticRegression(C=1.0, class_weight=None, dual=False, fit_intercept=True,
intercept_scaling=1, max_iter=1...bs=1,
penalty='l2', random_state=None, solver='newton-cg', tol=0.0001,
verbose=0, warm_start=False)
multi_class = 'ovr'
solver = 'newton-cg'
y_32 = array([0., 1., 1.], dtype=float32)
y_64 = array([0., 1., 1.])
Observed on 32-bit Python 3.6:
https://ci.appveyor.com/project/raghavrv/scikit-learn/build/1.0.10326/job/q26cgwt9ht2k4g8o?fullLog=true
but also on 32-bit Python 3.6 on the 0.19.X branch when trying to build the wheels:
Maybe the 32-bit compiler used by the Python 3 builds on appveyor has changed recently?
This is with the newton CG solver of scipy. Maybe we should just relax the tolerance but having to go from 7 decimals to just 3 decimals seems a bit fishy.
Metadata
Metadata
Assignees
Labels
BlockerBugModerateAnything that requires some knowledge of conventions and best practiceshelp wanted
Activity
ogrisel commentedon Jul 5, 2018
Also observed with 32-bit Python 3.5:
https://ci.appveyor.com/project/sklearn-wheels/scikit-learn-wheels/build/job/f29gbrmuhdfsmc7f
ogrisel commentedon Jul 5, 2018
If someone with access to a windows dev environment with 32-bit Python and well configured visual studio compilers for Python 3.5+ would try to help that would be wonderful.
First: try to reproduce.
Second: try to understand what's going on.
massich commentedon Jul 16, 2018
I'm checking it.
massich commentedon Jul 16, 2018
Probably the error comes from the fact that
LogisticRegressionis called several times to populate:lr_32,lr_32_sparseandlr_64; and the random seed is not fixed. So the results might differ.massich commentedon Jul 16, 2018
I'm not able to reproduce it.
I'll run it a bit longer.
massich commentedon Jul 17, 2018
I run it longer, I could not replicate either. I'll submit the
random_seedchange and if this appears again, we can check it further.