python3 load Iris.data数据集出现报错key words: b'Iris-setosa'

通过搜索原因,发现有可能是在对文件读取是编译出现了问题,并且Keyword中提示b‘Iris-setosa‘,而我们的string转float函数中没有字母b,很奇怪。所以尝试将转换函数所有的string前加b。结果发现数据读取正常。
下边附上转换函数:

def iris_type(s):
    it = {b‘Iris-setosa‘: 0, b‘Iris-versicolor‘: 1, b‘Iris-virginica‘: 2}
    return it[s]

python3 load Iris.data数据集出现报错key words: b'Iris-setosa'

原文地址:https://www.cnblogs.com/zyt-bg/p/10376526.html

时间: 2024-07-30 12:40:48

python3 load Iris.data数据集出现报错key words: b'Iris-setosa'的相关文章

问题: Octave 改变文件目录后 pkg load 加载第三方库报错

懒得重新安装Octave,就直接从原来安装的目录中复制出来,使用pkg load image命令时会显示报错 pkg load image warning: addpath: "origin path " No such file or direct 显示的路径为原来的路径,应该在某个文件中记录了第一次安装的位置 octave-4.2.0-w64\share\octave\octave_packages 查找替换掉这个文件里所有的原有路径为当前路径即可 From WizNote

github添加ssh key报错Key is invalid. Ensure you've copied the file correctly

github添加ssh key的时候报错:Key is invalid. Ensure you've copied the file correctly 将秘钥复制粘贴到文本编辑器中,再粘贴复制到 github添加ssh key报错Key is invalid. Ensure you've copied the file correctly

python3的urllib以及urllib2的报错问题

1. urllib.urlencode(params) 换成 urllib.parse.urlencode(params) 2. 在python3.3后urllib2已经不能再用,只能用urllib.request来代替 response=urllib2.urlopen(' File "b.py", line 1, in <module> ImportError: No module named 'urllib2' response=urllib.urlopen('File

PrestaShop 修复Google Structured Data Testing Tool 报错

转载请注明出处:http://www.cnblogs.com/zhong-dev/p/4943065.html 网店版本 Prestashop v1.6 上图红框的地方,会缺少两个字段:price 和 priceCurrency,这个就需要修改模板了:product-list.tpl 解决方案: 使用 ftp 工具,进入到 Themes,进入目前使用的主题,找到 product-list.tpl 文件.使用 sublime 等编辑工具,搜索 href="http://schema.org/InS

python3.6使用chardet模块总是报错ValueError: Expected a bytes object, not a unicode object

py3里,字符串,str类型,是unicode编码格式.其他类型都是byte,编码格式是gbk,utf-8等 而chardet是检查byte类型的编码格式的,不是检查str类型的编码格式的. a="abc啊",是字符串,就不能用chardet了. 当获取的数据(byte)类型,需要当成字符串来处理,需要先将其编码成unicode(python处理的都是此编码). 而要将bytes转换成unicode,需要先知道bytes具体是什么编码格式如gbk,然后使用aa=decode("

mysq 安装时候进行生成数据库系统时候执行语句 ./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql 时候报错

我在安装数据库时候在系统进行生成数据库时候出现下面问题,就是在 scripts里面mysql_install_db没有执行权限, 进入到scripts目录下,执行chmod 777 mysql_install_db 给你所有权限,还真给面子,在执行图中语句时候,还真执行了.....

python3.7.3使用web.py报错解决办法 and RuntimeError: generator raised StopIteration

这是想要创建一个用python编写的web项目.但是首先要确定自己的web.py已经安装成功了. 安装的命令是: pip install web.py==0.40-dev1 运行官网的如下的实例: import weburls = ('/(.*)', 'hello')app = web.application(urls, globals()) class hello: def GET(self, name):if not name: name = 'World'return 'Hello, '

【spring data jpa】启动报错:nested exception is java.util.NoSuchElementException

spring boot项目中 使用spring data jpa 启动报错: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'dealerTransferServiceImpl': Unsatisfied dependency expressed through field 'dealerTransferDao'; nested exception i

mysql报错

1. 环境说明 CentOS 6.5 [[email protected] ~]# uname -a Linux linux-mysql02 2.6.32-431.el6.x86_64 #1 SMP Fri Nov 22 03:15:09 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux 2. 问题描述 编译安装MySQL-5.6.37和二进制安装MySQL-5.6.37,在初始化mysql后,它会自动在MYSQL_BASE目录下(/u02/mysql-5.6.37