当前位置:网站首页>成功解决(机器学习分割数据问题):ModuleNotFoundError: No module named ‘sklearn.cross_validation‘
成功解决(机器学习分割数据问题):ModuleNotFoundError: No module named ‘sklearn.cross_validation‘
2022-06-29 00:38:00 【无 羡ღ】
成功解决(机器学习分割数据问题):ModuleNotFoundError: No module named ‘sklearn.cross_validation’
报错代码
在机器学习中,将原始数据按照比例分割为“测试集”和“训练集”,经常使用sklearn.cross_validation里的train_test_split模块用来分割数据。
我的代码:
from sklearn.cross_validation import train_test_split
from sklearn.datasets import load_iris
iris = load_iris()
x_train, x_test, y_train, y_test = train_test_split(iris.data, iris.target, test_size=0.25, random_state=42)
print("训练集的特征值:", x_train)
print("测试集的特征值:", x_test)
print("训练集的目标值:", y_train)
print("测试集的目标值:", y_test)
print("训练集的目标值形状:", y_train.shape)
print("测试集的目标值形状:", y_test.shape)
报错结果:
from sklearn.cross_validation import train_test_split
ModuleNotFoundError: No module named 'sklearn.cross_validation'

解决思路
报错内容翻译:ModuleNotFoundError:没有名为“sklearn”的模块。cross\u验证’
报错原因:最新sklearn模块中,目前train_test_split已经没有cross_validation了
解决方法
导包代码换成如下即可:
from sklearn.model_selection import train_test_split
边栏推荐
- How the slip ring motor works
- [staff] accent mark, gradually stronger mark and gradually weaker mark
- 请问基金是否靠谱,安全吗
- scp拷贝文件夹
- User login (remember the user) & user registration (verification code) [using cookie session technology]
- Technology sharing | software development process that you must understand if you want to get started with testing
- Daily practice: delete duplicates in the ordered array
- 矩 阵 压 缩
- 单机多实例MYSQL主从复制
- Xiaobai's e-commerce business is very important to choose the right mall system!
猜你喜欢

Nodejs安装和下载

【leetcode】17. Letter combination of telephone number

手下两个应届生:一个踏实喜欢加班,一个技术强挑活,怎么选??

12.物体检测Mask-Rcnn
JVM底层又是如何实现synchronized的

Analysis of basic structure and working principle of slip ring

Nodejs installation and download

Comparison between winding process and lamination process

浏览器缓存库设计总结(localStorage/indexedDB)

Use and principle of handlerthread
随机推荐
After eight years of testing and opening experience and interview with 28K company, hematemesis sorted out high-frequency interview questions and answers
Click hijack: X-FRAME-OPTIONS is not configured
Phoenix installation tutorial
这玩意叫跳表?
搭建单机 nacos 负载均衡ribbon 轮询策略 权重2种方式
With notes: re understanding else if
MapReduce case
Is pension insurance a financial product? Where is the expected return?
Summary of the 25-year-old Ma Nong who graduated three years ago
单机多实例MYSQL主从复制
Remove HTML tags from Oracle
EditText监听焦点
Redis是什么
卷绕工艺与叠片工艺的对比
Windows平台下安装MySQL(附:Navicat Premium 12 “使用” 教程)
Précautions d'installation et d'utilisation des joints rotatifs
[image registration] SAR image registration based on particle swarm optimization Improved SIFT with matlab code
Two fresh students: one is practical and likes to work overtime, and the other is skilled. How to choose??
Document management.
Realization of beauty system with MATLAB