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 . ...
随机推荐
- Rob Pike 编程五原则
Rob Pike's 5 Rules of Programming Rule 1: You can't tell where a program is going to spend its time. ...
- BZOJ4551[Tjoi2016&Heoi2016]树——dfs序+线段树/树链剖分+线段树
题目描述 在2016年,佳媛姐姐刚刚学习了树,非常开心.现在他想解决这样一个问题:给定一颗有根树(根为1),有以下 两种操作:1. 标记操作:对某个结点打上标记(在最开始,只有结点1有标记,其他结点均 ...
- BZOJ2124 等差子序列(树状数组+哈希)
容易想到一种暴力的做法:枚举中间的位置,设该位置权值为x,如果其两边存在权值关于x对称即合法. 问题是如何快速寻找这个东西是否存在.考虑仅将该位置左边出现的权值标1.那么若在值域上若关于x对称的两权值 ...
- BZOJ4943 NOI2017蚯蚓排队(哈希+链表)
能看懂题就能想到正解.维护所有长度不超过k的数字串的哈希值即可,用链表维护一下蚯蚓间连接情况.由于这样的数字串至多只有nk个,计算哈希值的总复杂度为O(nk),而分裂的复杂度为O(ck^2),询问复杂 ...
- BZOJ5338 [TJOI2018] Xor 【可持久化Trie树】【dfs序】
题目分析: 很无聊的一道题目.首先区间内单点对应异或值的询问容易想到trie树.由于题目在树上进行,case1将路径分成两段,然后dfs的时候顺便可持久化trie树做询问.case2维护dfs序,对d ...
- WordPress发送注册用户设置密码邮件提示:您的密码重设链接无效,请在下方请求新链接
1.修改WP根目录下的 wp-login.php文件将 $message .= '<' . network_site_url("wp-login.php?action=rp&k ...
- hdu1176 (免费馅饼)
免费馅饼 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submis ...
- activity中访问内部fragment的函数
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCod ...
- 【LOJ#10002】喷水装置
题目大意:给定一段区间 [l,r] ,N 条线段,求至少用多少条线段能够覆盖整个区间,不能覆盖输出-1. 题解:每次在起点小于当前位置的线段集合中选择有端点最大的位置作为下一个位置,并更新答案,如果当 ...
- (Arrays.sort() 或 map) Ignatius and the Princess IV hdu1029
Ignatius and the Princess IV 链接:http://acm.hdu.edu.cn/showproblem.php?pid=1029 借鉴链接:https://blog.csd ...