Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I solve cannot import name 'fetch_openml' from 'sklearn.datasets'

Tags:

scikit-learn

I'm learning sklearn, but I can't use fetch_openml(). It says,

ImportError: cannot import name 'fetch_openml' from 'sklearn.datasets'

like image 309
Zhang Avatar asked Sep 19 '25 00:09

Zhang


2 Answers

In the new version of sklearn, it's even easier to fetch open ML Datasets. For example, you can add import and fetch mnist dataset as:

from sklearn.datasets import fetch_openml
X, y = fetch_openml('mnist_784', version=1, return_X_y=True, as_frame=False)
print(X.shape, y.shape)

For more details check official example.

like image 133
DevLoverUmar Avatar answered Sep 23 '25 07:09

DevLoverUmar


Apparently, fetch_mldata has been deprecated in the newer sklearn. Use load_digits to achieve loading the MNIST data.

like image 38
SKPS Avatar answered Sep 23 '25 06:09

SKPS