当前位置: 动力学知识库 > 问答 > 编程问答 >

python - ImportError: cannot import name '_safe_split'

问题描述:

I got the following errors when I tried to use the train_test_split function. Then I tried to install scipy, but it didn't help. Does anyone know which I might be missing from the error below? Thanks!


ImportError Traceback (most recent call last)

<ipython-input-53-57bf27feca45> in <module>()

1 import numpy as np

----> 2 from sklearn.model_selection import train_test_split

3

4 X_train, X_test, y_train, y_test = train_test_split(X, Y, test_size=0.33, random_state=42)

/usr/local/lib/python3.4/dist-packages/sklearn/model_selection/__init__.py in <module>()

15 from ._split import check_cv

16

---> 17 from ._validation import cross_val_score

18 from ._validation import cross_val_predict

19 from ._validation import learning_curve

/usr/local/lib/python3.4/dist-packages/sklearn/model_selection/_validation.py in <module>()

25 from ..utils.fixes import astype

26 from ..utils.validation import _is_arraylike, _num_samples

---> 27 from ..utils.metaestimators import _safe_split

28 from ..externals.joblib import Parallel, delayed, logger

29 from ..metrics.scorer import check_scoring

ImportError: cannot import name '_safe_split'

网友答案:

I solved this same problem by updating the version of scikit to 0.18.1

网友答案:

I had same problem and solved by importing "Scipy", "Numpy", "Pandas", "Matplotlib" and initially I updated "Scikit-learn".

分享给朋友:
您可能感兴趣的文章:
随机阅读: