AttributeError:类型对象“ sklearn.tree._criterion.array”没有属性“ __reduce_cython__”

时间:2019-12-11 20:15:29

标签: python scikit-learn artificial-intelligence decision-tree

我要导入 from sklearn.tree import DecisionTreeRegressor in jupyter。 但是当我只运行包含以上import的行时,出现此错误。

<ipython-input-16-28b3e81cd98d> in <module>
----> 1 from sklearn.tree import DecisionTreeRegressor

~/.local/lib/python3.6/site-packages/sklearn/tree/__init__.py in <module>
      4 """
      5 
----> 6 from ._classes import BaseDecisionTree
      7 from ._classes import DecisionTreeClassifier
      8 from ._classes import DecisionTreeRegressor

~/.local/lib/python3.6/site-packages/sklearn/tree/_classes.py in <module>
     38 from ..utils.validation import check_is_fitted
     39 
---> 40 from ._criterion import Criterion
     41 from ._splitter import Splitter
     42 from ._tree import DepthFirstTreeBuilder

~/.local/lib/python3.6/site-packages/sklearn/tree/_criterion.cpython-36m-x86_64-linux-gnu.so in init sklearn.tree._criterion()

AttributeError: type object 'sklearn.tree._criterion.array' has no attribute '__reduce_cython__'

我尝试通过conda安装scipy并更新scikit-learn,但没有解决。

1 个答案:

答案 0 :(得分:1)

尝试更新Cython:

pip install cython