English 中文(简体)
Scikit-learn - Cannotload MNIST 原始数据集
原标题:Scikit-learn - Cannot load MNIST Original dataset using fetch_openml in Python

I m 试图装满NMNIST原始数据集。 <代码>sklearn.datasets.fetch_ openml功能似乎在发挥作用。

这里是使用Im的代码。

from sklearn.datasets import fetch_openml
dataset = fetch_openml("MNIST Original") 

我发现这一错误。

File "generateClassifier.py", line 11, in <module>
  dataset = fetch_openml("MNIST Original")
  File "/home/inglorion/.local/lib/python3.5/site- 
packages/sklearn/datasets/openml.py", line 526, in fetch_openml
data_info = _get_data_info_by_name(name, version, data_home)
  File "/home/inglorion/.local/lib/python3.5/site- 
packages/sklearn/datasets/openml.py", line 302, in 
_get_data_info_by_name
    data_home)
  File "/home/inglorion/.local/lib/python3.5/site- 
packages/sklearn/datasets/openml.py", line 169, in 
_get_json_content_from_openml_api
    raise error
  File "/home/inglorion/.local/lib/python3.5/site- 
packages/sklearn/datasets/openml.py", line 164, in 
_get_json_content_from_openml_api
    return _load_json()
  File "/home/inglorion/.local/lib/python3.5/site- 
packages/sklearn/datasets/openml.py", line 52, in wrapper
    return f()
  File "/home/inglorion/.local/lib/python3.5/site- 
packages/sklearn/datasets/openml.py", line 160, in _load_json
    with closing(_open_openml_url(url, data_home)) as response:
  File "/home/inglorion/.local/lib/python3.5/site- 
packages/sklearn/datasets/openml.py", line 109, in _open_openml_url
with closing(urlopen(req)) as fsrc:
  File "/usr/lib/python3.5/urllib/request.py", line 163, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python3.5/urllib/request.py", line 472, in open
    response = meth(req, response)
  File "/usr/lib/python3.5/urllib/request.py", line 582, in 
http_response
     http , request, response, code, msg, hdrs)
  File "/usr/lib/python3.5/urllib/request.py", line 510, in error
    return self._call_chain(*args)
  File "/usr/lib/python3.5/urllib/request.py", line 444, in 
_call_chain
    result = func(*args)
  File "/usr/lib/python3.5/urllib/request.py", line 590, in 
http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
        urllib.error.HTTPError: HTTP Error 400: Bad Request

我如何确定这一点? 另一种方式是,是否还有其他方式将多国专家小组的数据集装入沙丘?

I m 采用scikit-learn0.2版。

I m relatively new to programming in general, so I would appreciate it if I could get a simple answer. Thanks!

问题回答

Try

mnist = fetch_openml( mnist_784 )

I found it via https://www.openml.org/ under https://www.openml.org/d/554

Method fetch_openml() download dataset from mldata.org which is not stable and can not connect. An alternative way is manually to download the data set from the original data. You can download data from Kaggle(mnist data) and run the following code

from scipy.io import loadmat
mnist = loadmat("../input/mnist-original.loadmat")
mnist_data = mnist["data"].T
mnist_label = mnist["label"][0]

you can use:

mist = fetch_openml( mnist_784 , version=1)

fetch_mldata is deprecated since scikit-learn v0.20

Test sklearn version

import sklearn
sklearn.__version__

Import Dataset

from sklearn.datasets import fetch_openml
X, y = fetch_openml( mnist_784 , version=1, return_X_y=True)

Example

I was also facing similar problem. Updating sklearn s version worked for me

我刚刚掌握以下指挥权:

conda update scikit-learn

然后,你可以做这样的事情。

import nltk
import sklearn

print( nltk version: {}. .format(nltk.__version__))
print( scikit-learn version: {}. .format(sklearn.__version__))

不要忘记在更新雕刻版后重新启用炉.。

mnist = fetch_openml(mnist_784)





相关问题
Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

An enterprise scheduler for python (like quartz)

I am looking for an enterprise tasks scheduler for python, like quartz is for Java. Requirements: Persistent: if the process restarts or the machine restarts, then all the jobs must stay there and ...

How to remove unique, then duplicate dictionaries in a list?

Given the following list that contains some duplicate and some unique dictionaries, what is the best method to remove unique dictionaries first, then reduce the duplicate dictionaries to single ...

What is suggested seed value to use with random.seed()?

Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...

How can I make the PyDev editor selectively ignore errors?

I m using PyDev under Eclipse to write some Jython code. I ve got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ...

How do I profile `paster serve` s startup time?

Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

Converting Dictionary to List? [duplicate]

I m trying to convert a Python dictionary into a Python list, in order to perform some calculations. #My dictionary dict = {} dict[ Capital ]="London" dict[ Food ]="Fish&Chips" dict[ 2012 ]="...

热门标签