简体   繁体   English

导入 train_test_split 时模块导入错误

[英]Module import error while importing train_test_split

I am trying to import the train_test_split from sklearn by using我正在尝试通过使用从sklearn导入train_test_split

 from sklearn.cross_validation import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.2, random_state = 0)

Every time I am getting the same error saying:每次我得到同样的错误说:

Module import error, module not found

I have tried creating a virtual environment in conda and also ran我尝试在 conda 中创建虚拟环境并运行

conda update -all康达更新-全部

I am still getting the same error.我仍然遇到同样的错误。

Replace代替

from sklearn.cross_validation import train_test_split

By经过

from sklearn.model_selection import train_test_split

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从 sklearn.model_selection 导入 train_test_split 时,为什么我收到错误“AttributeError: module 'attr' has no attribute 's'”? - While importing train_test_split from from sklearn.model_selection, why am I getting the error "AttributeError: module 'attr' has no attribute 's'"? 实现train_test_split时的ValueError - ValueError while implementing the train_test_split 拟合训练集和测试集时出错,train_test_split 方法 - Error while fitting train and test sets, train_test_split method 导入错误 - 无法从“sklearn.preprocessing”导入名称“train_test_split” - import error for -cannot import name 'train_test_split' from 'sklearn.preprocessing' 类型错误:尝试使用 train_test_split() 在 python 中拆分数据集时出现单例数组 - Type error:Singleton array while trying to split the dataset in python using train_test_split() train_test_split:值错误 - train_test_split: ValueError 我不能使用 train_test_split 。这个模块不工作 - I am not able to use train_test_split .This module is not working 在 Kaggle 内核上使用 train_test_Split 方法时显示错误。 帮助表示赞赏 - Showing Error while using train_test_Split method to on Kaggle kernal. Help appreciated 在维护索引的同时绘制train_test_split - plotting train_test_split while maintining their indices sklearn train_test_split 运行两次报错 - Sklearn train_test_split reporting error when running twice
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM