python - 值错误 : Dataset with data_id 554 not found

标签 python scikit-learn mnist

我正在对 MNIST 数据集进行分类算法。当我使用 sklearn.datasets 加载数据集时

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

执行这段代码后我遇到了一个大错误。

<ipython-input-2-00e245087535> in <module>
----> 1 mnist = fetch_openml('mnist_784', version=1)

/opt/conda/lib/python3.7/site-packages/sklearn/utils/validation.py in inner_f(*args, **kwargs)
     70                           FutureWarning)
     71         kwargs.update({k: arg for k, arg in zip(sig.parameters, args)})
---> 72         return f(**kwargs)
     73     return inner_f
     74 

/opt/conda/lib/python3.7/site-packages/sklearn/datasets/_openml.py in fetch_openml(name, version, data_id, data_home, target_column, cache, return_X_y, as_frame)
    807         # The shape must include the ignored features to keep the right indexes
    808         # during the arff data conversion.
--> 809         data_qualities = _get_data_qualities(data_id, data_home)
    810         shape = _get_num_samples(data_qualities), len(features_list)
    811     else:

/opt/conda/lib/python3.7/site-packages/sklearn/datasets/_openml.py in _get_data_qualities(data_id, data_home)
    420     error_message = "Dataset with data_id {} not found.".format(data_id)
    421     json_data = _get_json_content_from_openml_api(url, error_message, True,
--> 422                                                   data_home)
    423     try:
    424         return json_data['data_qualities']['quality']

/opt/conda/lib/python3.7/site-packages/sklearn/datasets/_openml.py in _get_json_content_from_openml_api(url, error_message, raise_if_error, data_home)
    168     # 412 error, not in except for nicer traceback
    169     if raise_if_error:
--> 170         raise ValueError(error_message)
    171     return None
    172 

ValueError: Dataset with data_id 554 not found.

如何获取数据?

最佳答案

代码片段 1

X, y = fetch_openml('mnist_784', version=1, return_X_y=True)

代码片段2

data = fetch_openml('mnist_784')

这两个代码都应该有效。但是通过使用代码片段 1,您可以默认提及版本并分配标签和功能。

由于与 fetch_openml 相关的缓存错误,您上面提到的代码无法正常工作。

关于python - 值错误 : Dataset with data_id 554 not found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65033069/

相关文章:

python - 使用 hmmlearn 收敛到一种状态的隐马尔可夫模型

python - 删除 Bert 中的 SEP token 以进行文本分类

python - 应用于每一列的 Pandas value_counts

python - Scikit-learn KNN(K 最近邻)使用 Apache Spark 并行化

python - Tfidf内存错误: How to avoid this issue?

python - '导入错误: DLL load failed' when fetching MNIST original via sklearn

python - 自然场景数字识别的深度学习解决方案

python - Matplotlib 代码由于标签而无法执行?

python - 使用 sklearn 获取每个 ngram 术语的频率

machine-learning - 在测试 MNIST 时,caffe 测试错误没有名为 "net"的字段