Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sklearn import error - ImportError: cannot import name 'comb'

I am trying to do this:

from sklearn.model_selection import train_test_split

and getting an error:

In [31]: from sklearn.model_selection import train_test_split
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-31-73edc048c06b> in <module>()
----> 1 from sklearn.model_selection import train_test_split

/usr/local/lib/python3.6/site-packages/sklearn/model_selection/__init__.py in <module>()
----> 1 from ._split import BaseCrossValidator
      2 from ._split import KFold
      3 from ._split import GroupKFold
      4 from ._split import StratifiedKFold
      5 from ._split import TimeSeriesSplit

/usr/local/lib/python3.6/site-packages/sklearn/model_selection/_split.py in <module>()
     29 from ..externals.six import with_metaclass
     30 from ..externals.six.moves import zip
---> 31 from ..utils.fixes import signature, comb
     32 from ..base import _pprint
     33 

ImportError: cannot import name 'comb'

any help would be much apreciated.

like image 558
steff Avatar asked Nov 07 '17 06:11

steff


1 Answers

SciPy >=0.19 uses from scipy.special import comb instead of from scipy.misc import comb. https://github.com/scikit-learn/scikit-learn/pull/9046

utils/fixes.py source

try:  # SciPy >= 0.19
    from scipy.special import comb, logsumexp
except ImportError:
    from scipy.misc import comb, logsumexp  # noqa 
like image 159
qwr Avatar answered Sep 22 '22 05:09

qwr