Closed
Labels
EasyWell-defined and straightforward way to resolvegood first issueEasy with clear instructions to resolve
Description
Description
test_predict_proba_binary fails with some random seed. I encountered this during PR #10058 , modifying by mistake the random state in tests
Steps/Code to Reproduce
from sklearn.neural_network.tests.test_mlp import test_predict_proba_binary
np.random.seed(2)
test_predict_proba_binary()Expected Results
No error is thrown
Actual Results
---------------------------------------------------------------------------
AssertionError Traceback (most recent call last)
<ipython-input-1-54c5d3efee13> in <module>
1 from sklearn.neural_network.tests.test_mlp import test_predict_proba_binary
2 np.random.seed(2)
----> 3 test_predict_proba_binary()
~/anaconda3/envs/env_test_mlp/lib/python3.7/site-packages/sklearn/neural_network/tests/test_mlp.py in test_predict_proba_binary()
448 assert_array_equal(y_log_proba, np.log(y_proba))
449
--> 450 assert_equal(roc_auc_score(y, y_proba[:, 1]), 1.0)
451
452
~/anaconda3/envs/env_test_mlp/lib/python3.7/unittest/case.py in assertEqual(self, first, second, msg)
837 """
838 assertion_func = self._getAssertEqualityFunc(first, second)
--> 839 assertion_func(first, second, msg=msg)
840
841 def assertNotEqual(self, first, second, msg=None):
~/anaconda3/envs/env_test_mlp/lib/python3.7/unittest/case.py in _baseAssertEqual(self, first, second, msg)
830 standardMsg = '%s != %s' % _common_shorten_repr(first, second)
831 msg = self._formatMessage(msg, standardMsg)
--> 832 raise self.failureException(msg)
833
834 def assertEqual(self, first, second, msg=None):
AssertionError: 0.5 != 1.0
Versions
System:
python: 3.7.1 (default, Oct 23 2018, 19:19:42) [GCC 7.3.0]
executable: /home/will/anaconda3/envs/env_test_mlp/bin/python
machine: Linux-4.4.0-139-generic-x86_64-with-debian-stretch-sid
BLAS:
macros: SCIPY_MKL_H=None, HAVE_CBLAS=None
lib_dirs: /home/will/anaconda3/envs/env_test_mlp/lib
cblas_libs: mkl_rt, pthread
Python deps:
pip: 18.1
setuptools: 40.6.2
sklearn: 0.21.dev0
numpy: 1.15.4
scipy: 1.1.0
Cython: None
pandas: None
Metadata
Metadata
Assignees
Labels
EasyWell-defined and straightforward way to resolvegood first issueEasy with clear instructions to resolve
Activity
jnothman commentedon Dec 12, 2018
So the test should at least fix its random seed... or we need a stronger test.
xhan7279 commentedon Dec 14, 2018
First timer here. I took a look at the test and am not sure why the random state would affect the output of MLPClassifier. Specifying a random state when initializing the classifier does fix the issue. Should I go ahead?
adrinjalali commentedon Dec 16, 2018
Sure, go ahead @xhan7279 .