我正在尝试从train_test_split()
导入sklearn.cross_validation
,但是出现类似“没有名为'sklearn.cross_validation的模块”之类的错误,但是我已经在anaconda中安装了scikit-learn。因此,如何解决这一点是无法理解的。
from sklearn.cross_validation import train_test_split
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-20-d05cc6ee7707> in <module>
----> 1 from sklearn.cross_validation import train_test_split
ModuleNotFoundError: No module named 'sklearn.cross_validation'
答案 0 :(得分:0)
使用以下内容。从sklearn.cross_validation导入import train_test_split
from sklearn.model_selection import train_test_split
答案 1 :(得分:-1)
运行
from sklearn.model_selection import train_test_split
代替
from sklearn.cross_validation import train_test_split
谢谢!
答案 2 :(得分:-2)
因此,不必使用index
,而必须使用
sklearn.cross_validation
这是因为from sklearn.model_selection import train_test_split
已被弃用。