解决: DeprecationWarning: Passing 1d arrays as data is deprecated in 0.17 and will raise ValueError in 0.19
错误信息:
C:\Python27\lib\site-packages\sklearn\utils\validation.py:395: DeprecationWarning: Passing 1d arrays as data is deprecated in 0.17 and will raise ValueError in 0.19. Reshape your data either using X.reshape(-1, 1) if your data has a single feature or X.reshape(1, -1) if it contains a single sample.
DeprecationWarning) 这个warning纠结了一下午,一开始我以为是在GaussianNB().fit()里头出错 -_-b
最后debug了一下发现原来是predict()的问题, predict的参数要求是数组, 而我传进去的是list.转换一下就OK了(红色部分) clf = GaussianNB().fit(trainMat2d, Y)
s1 = u"关于 xzmxzm2323 和 他 马甲 XBOX360 高 教授 版主 还有 大家 都 进来 看下 兄弟 不要 和 神经病 较真 我 觉得 他 精神 真的 有点 不 正常"
s2 = u"求 2016 ps4 中 超 队徽 申花 及 天津 权健 队服 及 队徽"
s3 = u"PES 2016 Super Patch 0.2 好 快 都 出 0.2 了"
ary1 = s1.split(' ')
ary2 = s2.split(' ')
ary3 = s3.split(' ') d = pb.setOfWords2Vec(C, ary1)
print type(d)
print d
thisDoc1 = array(d).reshape((1,-1))
print type(thisDoc1)
print thisDoc1
print 'S1 classifed as %d' %(clf.predict(thisDoc1))' 运行结果:
Building trainning matrix completed
<type 'list'>
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ..., 0, 0]
<type 'numpy.ndarray'>
[[0 0 0 ..., 0 0 0]]
S1 classifed as 1
解决: DeprecationWarning: Passing 1d arrays as data is deprecated in 0.17 and will raise ValueError in 0.19的更多相关文章
- 解决如下出错:DeprecationWarning: Passing 1d arrays as data is deprecated in 0.17 and willraise ValueError in 0.19.
背景:在Spyder中写几行脚本,目的是应用sklearn自带的svm(支持向量机)算法,来对其自带的digits(手写体数字)数据集进行分类,过程包括训练阶段和预测阶段.将手写体数字数据的特征数据d ...
- 关于Visio Studio 2012使用Nuget获取Sqlite驱动包报错:“System.Data.SQLite.EF6”的架构版本与 NuGet 的版本 2.0.30625.9003 不兼容
背景 笔者的VS2012版本比较老旧,是几年以前下载的.平时添加三方包和驱动包都是手动添加.后来了解到有Nuget这个工具,如获至宝.可是在使用过程中却出了不少问题. 最初,笔者尝试使用Nuget添加 ...
- 解决Error: ENOENT: no such file or directory, scandir 'D:\IdeaWork\code-front-jet\node_modules\.npminstall\node-sass\3.7.0\node-sass\vendor'
在使用npm安装node-sass的时候,可能会出现如下的报错: Error: ENOENT: no such file or directory, scandir 'D:\IdeaWork\code ...
- 解决Oracle出现以0开头的小数,开头的0消失的问题
项目中碰到了个问题,本来报表需要显示“0.49%”,结果就是显示成“.49%” 找问题 首先在pl/sql工具里执行sql,发现原始的数据就是“.49%”,那么问题来了,原始sql的问题,跟工具无关了 ...
- 解决:启动项目报错 java.lang.UnsatisfiedLinkError: D:\Java\apache-tomcat-8.0.17\bin\tcnative-1.dll: Can't load IA 32-bit .dll on a AMD 64-bit platform
启动项目报错如下: java.lang.UnsatisfiedLinkError: D:\Java\apache-tomcat-8.0.17\bin\tcnative-1.dll: Can't loa ...
- 解决gpg failed to sign the data fatal: failed to write commit object解决方案
今天有位新同事在comit代码的时候一直报这个错误: gpg failed to sign the data fatal: failed to write commit object. 看到网上说gp ...
- 解决eclipse+adt出现的 loading data for android 问题
因为公司最近做的项目中有用到一些第三方demo,蛋疼的是这些demo还比较旧...eclipse的... 于是给自己的eclipse装上了ADT插件,但是...因为我的eclipse比较新,Versi ...
- 解决还原数据库是出现system.data.sqlclient.sqlerror filestream功能被禁用的问题
在master数据库下新建查询 输入如下语句: USE master GO RECONFIGURE 执行 成功还原数据库
- [Nuxt] Add Arrays of Data to the Vuex Store and Display Them in Vue.js Templates
You add array of todos to the store simply by adding them to the state defined in your store/index.j ...
随机推荐
- 使用脚本操作UpdatePanel中控件的问题
假设有一个脚本(用js或者jQuery等类似手段编写),为UpdatePanel中的一个普通的TextBox赋值.如果你以为这样写: <head runat="server" ...
- ie6,ie7,ie8 css bug兼容解决记录
ie6,ie7,ie8 css bug兼容解决记录 转载自:ie6,ie7,ie8 css bug兼容解决记录 - 前端开发 断断续续的在开发过程中收集了好多的bug以及其解决的办法,都在这个文章里面 ...
- APP接口自动化测试JAVA+TestNG(一)之框架环境搭建
前言 好久不曾写点啥,去年换到新公司组测试团队与培养建设花费大量时间与精力,终于架构成型与稳定有时间可以打打酱油了.很久没有总结点啥,提笔想写的内容太多,先放APP接口自动化的内容吧,这个估计大家比较 ...
- Autofac - 程序集扫描
通过程序集扫描, 能够自动注册符合规则的类型. 这种方式, 很方便. 这一篇就介绍下程序集扫描吧. 一.扫描 其实前面已经介绍过, 这种方式. 不过并不全. 先看一个之前的方式: var builde ...
- jquery属性
1.toggleClass() 如果对象有class属性,则删除: 如果没有class属性,则加上. <style> .hide{ display: none; } </style ...
- 从零开始学Python第八周:网络编程基础(socket)
Socket网络编程 一,Socket编程 (1)Socket方法介绍 Socket是网络编程的一个抽象概念.通常我们用一个Socket表示"打开了一个网络链接",而打开一个Soc ...
- 领域驱动设计常见问题FAQ
本文出处:http://www.cqrs.nu/Faq What is a domain? The field for which a system is built. Airport managem ...
- Lind.DDD.API核心技术分享
回到目录 关于Lind.DDD框架里API框架的技术点说明 讲解:张占岭 花名:仓储大叔 主要框架:Lind.DDD 目录 关于Lind.DDD.Authorization 关于授权的原理 关于Api ...
- http cancelled状态与ajax 超时
在最近一周,我们的前端在测试某些批量超过的某个步骤时,发现请求好像发出来,但是后台状态没有变化,说是最近才出现的问题,以前一直都是正常的,两天连续出现两次之后,来找笔者,首先检查了下中间件的日志,发现 ...
- angularjs+微信,解决chooseImage不能预览的问题
在wx.chooseImage的success回调中直接进行数据绑定,却在ng-repeat时发现ng-src不加载微信localId的问题,类似wxLocalResource://imageid98 ...