尝试从sklearn导入MNIST数据时出现“ HTTPError:错误请求”

时间:2019-05-01 02:49:13

标签: python scikit-learn mnist

我正在尝试遵循“使用Scikit-Learn和Tensorflow进行机器学习动手”和练习请求之一来加载MNIST数据集。我按照下面的代码

    from sklearn.datasets import fetch_openml
    mnist = fetch_openml('MNIST_784', version = 1)

但是我收到以下回溯错误:

Traceback (most recent call last):

  File "<ipython-input-15-a3c5f878b528>", line 1, in <module>
    mnist = fetch_openml('MNIST original', version = 1)

  File "C:\Users\USERNAME\AppData\Local\Continuum\anaconda3\lib\site-packages\sklearn\datasets\openml.py", line 563, in fetch_openml
    data_info = _get_data_info_by_name(name, version, data_home)

  File "C:\Users\USERNAME\AppData\Local\Continuum\anaconda3\lib\site-packages\sklearn\datasets\openml.py", line 323, in _get_data_info_by_name
    data_home)

  File "C:\Users\USERNAME\AppData\Local\Continuum\anaconda3\lib\site-packages\sklearn\datasets\openml.py", line 172, in _get_json_content_from_openml_api
    raise error

  File "C:\Users\USERNAME\AppData\Local\Continuum\anaconda3\lib\site-packages\sklearn\datasets\openml.py", line 167, in _get_json_content_from_openml_api
    return _load_json()

  File "C:\Users\USERNAME\AppData\Local\Continuum\anaconda3\lib\site-packages\sklearn\datasets\openml.py", line 55, in wrapper
    return f()

  File "C:\Users\USERNAME\AppData\Local\Continuum\anaconda3\lib\site-packages\sklearn\datasets\openml.py", line 163, in _load_json
    with closing(_open_openml_url(url, data_home)) as response:

  File "C:\Users\USERNAME\AppData\Local\Continuum\anaconda3\lib\site-packages\sklearn\datasets\openml.py", line 112, in _open_openml_url
    with closing(urlopen(req)) as fsrc:

  File "C:\Users\USERNAME\AppData\Local\Continuum\anaconda3\lib\urllib\request.py", line 222, in urlopen
    return opener.open(url, data, timeout)

  File "C:\Users\USERNAME\AppData\Local\Continuum\anaconda3\lib\urllib\request.py", line 531, in open
    response = meth(req, response)

  File "C:\Users\USERNAME\AppData\Local\Continuum\anaconda3\lib\urllib\request.py", line 641, in http_response
    'http', request, response, code, msg, hdrs)

  File "C:\Users\USERNAME\AppData\Local\Continuum\anaconda3\lib\urllib\request.py", line 569, in error
    return self._call_chain(*args)

  File "C:\Users\USERNAME\AppData\Local\Continuum\anaconda3\lib\urllib\request.py", line 503, in _call_chain
    result = func(*args)

  File "C:\Users\USERNAME\AppData\Local\Continuum\anaconda3\lib\urllib\request.py", line 649, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)

HTTPError: Bad Request 

以下是我正在使用的sklearn的当前版本:

    print('The scikit-learn version is {}.'.format(sklearn.__version__))
    The scikit-learn version is 0.20.3.

我也在使用Anaconda Navigator,我认为可能是问题所在。我执行了“ conda update scikit-learn”,并假设我的软件包已经过时了,但是事实并非如此。

如果有类似问题的答案,请标记为重复。

0 个答案:

没有答案