Python提示AttributeError 或者DeprecationWarning: This module was deprecated解决方法
Python提示AttributeError 或者DeprecationWarning: This module was deprecated解决方法
在使用Python的sklearn库时,发现sklearn的cross_validation不能使用,在pycharm上直接显示为被横线划掉。
运行程序:
import sklearn
...
X, Xt, y, yt = sklearn.cross_validation.train_test_split(X, y)
报错:
AttributeError: 'module' object has no attribute 'cross_validation'
这里尝试修改为:
from sklearn.cross_validation import train_test_split
X, Xt, y, yt = train_test_split(X, y)
发现不再报错,而是提示警告信息:
**DeprecationWarning: This module was deprecated in version 0.18 in favor of the model_selection module into which all the refactored classes and functions are moved. Also note that the interface of the new CV iterators are different from that of this module. This module will be removed in 0.20.
"This module will be removed in 0.20.", DeprecationWarning) **
程序能够正常执行。
但是注意看提示信息,实际上是说cross_validation模块被弃用了,改为支持model_selection这个模块,因此,将程序改为:
from sklearn.model_selection import train_test_split
X, Xt, y, yt = train_test_split(X, y)
不再出现警告信息,一切正常。
Python提示AttributeError 或者DeprecationWarning: This module was deprecated解决方法的更多相关文章
- ImportError: No module named cv2 解决方法
ImportError: No module named cv2 解决方法 import cv2时会出现这个问题 解决方法:将openCV安装目录里的python文件夹内的cv2.pyd复制到Py ...
- Sublime2编译Python程序EOFError:EOF when reading a line解决方法【转】
在Sublime2中编译运行Python文件时,如果代码中包含用户输入的函数时(eg. raw_input()),Ctrl+b编译运行之后会提示以下错误: 解决方法:安装SublimeREPL打开Su ...
- Python3中使用HTMLTestRunner报No module named 'StringIO'解决方法
今天在学习使用HTMLTestRunner生成测试报告时遇到一个报错,如图所示: 网上搜索了下“No module named 'StringIO'”解决方法,原来我用的是Python 3.X版本,而 ...
- pip 安装使用 ImportError: No module named setuptools 解决方法
安装过程详见这篇博客: http://www.ttlsa.com/python/how-to-install-and-use-pip-ttlsa/ 安装后运行到:python setup.py ins ...
- VMware虚拟机提示“锁定文件失败 打不开磁盘”解决方法
VMware虚拟机提示“锁定文件失败 打不开磁盘”解决方法 摘自: http://www.xitongcheng.com/jiaocheng/xtazjc_article_40299.html 发布时 ...
- python 提示 AttributeError: module 'json' has no attribute 'dumps'
最近在学习python解析json的时候遇到问题, 提示 AttributeError: module 'json' has no attribute 'dumps' (模块没有dumps属性的意思) ...
- python程序在命令行执行提示ModuleNotFoundError: No module named 'XXX' 解决方法
在ide中执行python程序,都已经在默认的项目路径中,所以直接执行是没有问题的.但是在cmd中执行程序,所在路径是python的搜索路径,如果涉及到import引用就会报类似ImportError ...
- Python ImportError: No module named 'requests'解决方法
前言:最近在学习python,安装了python3.5的环境后,在网上下载了一个python文件运行的时候,提示ImportError: No module named 'requests'(找不到r ...
- Windows下运行python脚本报错“ImportError: No Module named ...”的解决方法
之前遇到一个问题,在Pycharm或IPython之类的IDE上运行脚本正常,但是直接运行或cmd命令行运行的时候报了模块未能找到的错误--ImportError: No Module named . ...
随机推荐
- UVa - 10339
It has been said that a watch that is stopped keeps better time than one that loses 1 second per day ...
- activity中访问内部fragment的函数
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCod ...
- 【loj3044】【zjoi2019】Minimax
题目 描述 给出一颗树,定义根节点1的深度为1,其他点深度为父亲深度+1: 如下定义一个点的点权: 1.叶子:为其编号:2.奇数深度:为其儿子编号最大值:3.偶数深度:为其儿子编号最小值: ...
- CF986C AND Graph
半年前做的一道题现在还是不会 x&y=0 意味着,x的补集的子集都是和x直接相连的 不妨令图中的点数就是2^n 那么可以直接从x^((1<<n)-1)开始记忆化爆搜,路上遇到的都是 ...
- SQL Server 增、删、改、小部分查
--现有三个表Student.Score.Course.Teacher create table Student ( Sno ) not null,--学号 Sname ) not null,--姓名 ...
- 【POJ1961】最短周期串/最大周期 kmp
引理:\(s[1,i]\) 具有长度为 \(len\) 的循环节的充要条件是:\(len\ |\ i,s[1,i-len]=s[len+1,i]\). 代码如下 #include <cstdio ...
- Pentaho data integration(kettle) 在Mac上启动不了
环境 MacOS Mojave (10.14.1) Pentaho Data Integration 8.2 Java 8 现象 从官方下载下来最新的安装包,解压之后,双击Data Integrati ...
- 获取Field成员变量类
位于java.lang.reflect.Field包中 getModifiers() 成员变量修饰符(public.private) getName() 成员变量名字 getType() 成员变量类型 ...
- MySQL中使用like查找汉字 Incorrect string value 解决办法
用Select…like %…%来查找MySQL的text类型字段的一个中文,却发现查出来的是乱的,发现不少人也遇到这样的问题.在中文排序和查找的时候,汉字的结果是错误的. 原因在于MySQL在查找字 ...
- Harbor镜像清理
目录 清理UI中的镜像 清理镜像释放空间 docker镜像仓库中镜像的清理,一直是个比较麻烦的事情.尤其是在测试环境当中,每天都会有大量的构建.由此会产生大量的历史镜像,而这些镜像,大多数都没有用. ...