from sklearn.cross_validation import train_test_split发生报错

简介: from sklearn.cross_validation import train_test_split发生报错

from sklearn.cross_validation import train_test_split发生报错

from sklearn.cross_validation import train_test_split

该导入命令在使用时会发生报错,因为现在版本的sklearn库中已经没有了cross_validation文件夹,train_test_split等现在放在model_selection文件夹中的_split.py文件里。
导入命令应调整为:

from sklearn.model_selection import train_test_split

这样即可正常运行了。
在这里插入图片描述

目录
相关文章
|
2月前
|
PyTorch 算法框架/工具
ImportError: cannot import name ‘_DataLoaderIter‘ from ‘torch.utils.data.dataloader‘
ImportError: cannot import name ‘_DataLoaderIter‘ from ‘torch.utils.data.dataloader‘
28 2
|
PyTorch 算法框架/工具 索引
详细介绍torch中的from torch.utils.data.sampler相关知识
PyTorch中的torch.utils.data.sampler模块提供了一些用于数据采样的类和函数,这些类和函数可以用于控制如何从数据集中选择样本。下面是一些常用的Sampler类和函数的介绍: Sampler基类: Sampler是一个抽象类,它定义了一个__iter__方法,返回一个迭代器,用于生成数据集中的样本索引。 RandomSampler: 随机采样器,它会随机从数据集中选择样本。可以设置随机数种子,以确保每次采样结果相同。 SequentialSampler: 顺序采样器,它会按照数据集中的顺序,依次选择样本。 SubsetRandomSampler: 子集随机采样器
537 0
|
TensorFlow API 算法框架/工具
解决AttributeError: module ‘keras.utils‘ has no attribute ‘plot_model‘
解决AttributeError: module ‘keras.utils‘ has no attribute ‘plot_model‘
279 0
解决AttributeError: module ‘keras.utils‘ has no attribute ‘plot_model‘
|
Python
解决ValueError: `validation_split` is only supported for Tensors or NumPy arrays, found following
解决ValueError: `validation_split` is only supported for Tensors or NumPy arrays, found following
586 0
解决ValueError: `validation_split` is only supported for Tensors or NumPy arrays, found following
|
机器学习/深度学习 并行计算 PyTorch
Pytorch 的 torch.utils.data.DataLoader 参数详解
Pytorch 的 torch.utils.data.DataLoader 参数详解
927 0
|
机器学习/深度学习 算法
ImportError: cannot import name ‘cross_validation‘ 解决方法
在学习机器学习分类算法 KNN 时,使用交叉验证时,调用了 cross_validation 函数,导入时报错。
330 0
ImportError: cannot import name ‘cross_validation‘ 解决方法
成功解决sklearn\preprocessing\label.py:151: DeprecationWarning: The truth value of an empty array is amb
成功解决sklearn\preprocessing\label.py:151: DeprecationWarning: The truth value of an empty array is amb
成功解决xgboost\core.py:614: UserWarning: Use subset (sliced data) of np.ndarray is not recommended beca
成功解决xgboost\core.py:614: UserWarning: Use subset (sliced data) of np.ndarray is not recommended beca
成功解决sklearn\ensemble\weight_boosting.py:29: DeprecationWarning: numpy.core.umath_tests is an interna
成功解决sklearn\ensemble\weight_boosting.py:29: DeprecationWarning: numpy.core.umath_tests is an interna
成功解决model_selection\_search.py:584: DeprecationWarning: "fit_params" as a constructor argument was d
成功解决model_selection\_search.py:584: DeprecationWarning: "fit_params" as a constructor argument was d