- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我正在尝试为一个简短的机器学习算法运行以下代码:
import re
import argparse
import csv
from collections import Counter
from sklearn import datasets
import sklearn
from sklearn.datasets import fetch_mldata
dataDict = datasets.fetch_mldata('MNIST Original')
在这段代码中,我试图通过 sklearn 读取 mldata.org 上的数据集“MNIST Original”。这会导致以下错误(有更多行代码,但我在这一行遇到错误):
Traceback (most recent call last):
File "C:\Program Files (x86)\JetBrains\PyCharm 2.7.3\helpers\pydev\pydevd.py", line 1481, in <module>
debugger.run(setup['file'], None, None)
File "C:\Program Files (x86)\JetBrains\PyCharm 2.7.3\helpers\pydev\pydevd.py", line 1124, in run
pydev_imports.execfile(file, globals, locals) #execute the script
File "C:/Users/sony/PycharmProjects/Machine_Learning_Homework1/zeroR.py", line 131, in <module>
dataDict = datasets.fetch_mldata('MNIST Original')
File "C:\Anaconda\lib\site-packages\sklearn\datasets\mldata.py", line 157, in fetch_mldata
matlab_dict = io.loadmat(matlab_file, struct_as_record=True)
File "C:\Anaconda\lib\site-packages\scipy\io\matlab\mio.py", line 176, in loadmat
matfile_dict = MR.get_variables(variable_names)
File "C:\Anaconda\lib\site-packages\scipy\io\matlab\mio5.py", line 294, in get_variables
res = self.read_var_array(hdr, process)
File "C:\Anaconda\lib\site-packages\scipy\io\matlab\mio5.py", line 257, in read_var_array
return self._matrix_reader.array_from_header(header, process)
File "mio5_utils.pyx", line 624, in scipy.io.matlab.mio5_utils.VarReader5.array_from_header (scipy\io\matlab\mio5_utils.c:5717)
File "mio5_utils.pyx", line 653, in scipy.io.matlab.mio5_utils.VarReader5.array_from_header (scipy\io\matlab\mio5_utils.c:5147)
File "mio5_utils.pyx", line 721, in scipy.io.matlab.mio5_utils.VarReader5.read_real_complex (scipy\io\matlab\mio5_utils.c:6134)
File "mio5_utils.pyx", line 424, in scipy.io.matlab.mio5_utils.VarReader5.read_numeric (scipy\io\matlab\mio5_utils.c:3704)
File "mio5_utils.pyx", line 360, in scipy.io.matlab.mio5_utils.VarReader5.read_element (scipy\io\matlab\mio5_utils.c:3429)
File "streams.pyx", line 181, in scipy.io.matlab.streams.FileStream.read_string (scipy\io\matlab\streams.c:2711)
IOError: could not read bytes
我曾尝试在互联网上进行研究,但几乎没有任何帮助。非常感谢任何与解决此错误相关的专家帮助。
TIA。
最佳答案
从 0.20 版开始,sklearn deprecates fetch_mldata
函数并添加 fetch_openml
相反。
下载MNIST dataset使用以下代码:
from sklearn.datasets import fetch_openml
mnist = fetch_openml('mnist_784')
虽然格式有一些变化。例如,mnist['target']
是一个字符串类别标签数组(不像以前那样是 float )。
关于python - 如何在 sklearn 中使用 datasets.fetch_mldata()?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19530383/
我导入了 fetch_mldata从 sklearn.datasets 导入 fetch_mldata并称: dataset = fetch_mldata('MNIST original') 但我得到
我正在尝试为一个简短的机器学习算法运行以下代码: import re import argparse import csv from collections import Counter from s
我想知道两者的区别 from sklearn import datasets dataset = datasets.fetch_mldata("MNIST Original") 和 from skle
我需要运行包含这些行的代码: from sklearn.datasets import fetch_mldata mnist = fetch_mldata('MNIST original') 执行起来
我是一名优秀的程序员,十分优秀!