在sklearn中使用datasets.fetch_mldata()时发生IO错误 [英] IO error when using datasets.fetch_mldata() in sklearn

查看:418
本文介绍了在sklearn中使用datasets.fetch_mldata()时发生IO错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我导入了fetch_mldata 从sklearn.datasets导入fetch_mldata 并致电:

I imported fetch_mldata from sklearn.datasets import fetch_mldata and called:

dataset = fetch_mldata('MNIST original')

但是我得到的是以下内容:

but what I get is the following:

> Traceback (most recent call last):   File "<stdin>", line 1, in
> <module>   File
> "C:\Users\Jacob\Development\Anaconda\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py",
> line 540, in runfile
>     execfile(filename, namespace)   File "C:/Users/Jacob/Documents/Dropbox/Technion/Semester 8/Machine
> learning/Demo3/Demo3.py", line 75, in <module>
>     dataset = fetch_mldata('MNIST original')    File "C:\Users\Jacob\Development\Anaconda\lib\site-packages\sklearn\datasets\mldata.py",
> line 158, in fetch_mldata
>     matlab_dict = io.loadmat(matlab_file, struct_as_record=True)   File
> "C:\Users\Jacob\Development\Anaconda\lib\site-packages\scipy\io\matlab\mio.py",
> line 126, in loadmat
>     matfile_dict = MR.get_variables(variable_names)   File "C:\Users\Jacob\Development\Anaconda\lib\site-packages\scipy\io\matlab\mio5.py",
> line 288, in get_variables
>     res = self.read_var_array(hdr, process)   File "C:\Users\Jacob\Development\Anaconda\lib\site-packages\scipy\io\matlab\mio5.py",
> line 248, in read_var_array
>     return self._matrix_reader.array_from_header(header, process)   File "mio5_utils.pyx", line 616, in
> scipy.io.matlab.mio5_utils.VarReader5.array_from_header
> (scipy\io\matlab\mio5_utils.c:5903)   File "mio5_utils.pyx", line 645,
> in scipy.io.matlab.mio5_utils.VarReader5.array_from_header
> (scipy\io\matlab\mio5_utils.c:5332)   File "mio5_utils.pyx", line 713,
> in scipy.io.matlab.mio5_utils.VarReader5.read_real_complex
> (scipy\io\matlab\mio5_utils.c:6323)   File "mio5_utils.pyx", line 417,
> in scipy.io.matlab.mio5_utils.VarReader5.read_numeric
> (scipy\io\matlab\mio5_utils.c:3873)   File "mio5_utils.pyx", line 353,
> in scipy.io.matlab.mio5_utils.VarReader5.read_element
> (scipy\io\matlab\mio5_utils.c:3595)   File "streams.pyx", line 324, in
> scipy.io.matlab.streams.FileStream.read_string
> (scipy\io\matlab\streams.c:4343) IOError: could not read bytes

我尝试下载sklearn的较新版本,但没有帮助. 我对这个问题有另一个看法,但是那里提供的解决方案并没有帮助我. 如何在sklearn中使用datasets.fetch_mldata()?

I tried downloading a newer version of sklearn but it didn't help. I so another thread about this problem but the offered solution there didn't help me. How to use datasets.fetch_mldata() in sklearn?

有什么想法吗?

推荐答案

供您/他人参考,我实际上得到了相同的错误(Ubuntu),包括"IOError:无法读取字节"错误.

For your/others' reference, I was getting virtually the same errors (Ubuntu), including that "IOError: could not read bytes" error.

我刚刚在发布了一个解决方案

I just posted a solution at

如何在sklearn?

简短答案-使用以下内容:

Short answer - use the following:

from sklearn.datasets.mldata import fetch_mldata
    data = fetch_mldata('mnist-original')

dataset = fetch_mldata('mnist-original', data_home='***')

用您喜欢的位置(数据目录)替换***(保留引号).

Replace *** (keep the quotes) with your preferred location (data directory).

这篇关于在sklearn中使用datasets.fetch_mldata()时发生IO错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆