我尝试使用train_testrongplit函数时会出现以下错误。然后我尝试安装Scipy,但这无济于事。有人知道我可能会从下面的错误中缺少哪些?谢谢!
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'
奇怪的事情是:升级到Scikit版本后,我发现了此错误
我重新启动了Python控制台,它解决了我的问题。
我通过将Scikit版本更新为0.18.1
我也有同样的问题,并通过导入" scipy"," numpy"," pandas"," matplotlib"来解决,最初我更新了" scikit-learn"。
在您更新Anaconda中的某些软件包后,通常会发生这种情况。请首先确认您是否也安装了Anaconda。尝试此操作以帮助您导入train_testrongplit:
from sklearn.cross_validation import train_test_split
如果工作起作用,请尝试使用conda和pip卸载它,然后将其安装在PIP上,查看是否可以使用常规方式导入它。我曾经在Python上不小心安装了" Scikit-Learn"one_answers" Sklearn"软件包,这也可能导致问题。