gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 13:11:13 25 4
gpt4 key购买 nike

我正在对 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com