from sklearn.datasets import fetchmldata ImportError: cannot import name 'fetchmldata'…
- User
from sklearn.datasets import fetch_mldata ImportError: cannot import name 'fetch_mldata' from 'sklearn.datasets' (C:\Users\AME\AppData\Local\Programs\Python\Python311\Lib\site-packages\sklearn\datasets_init_.py) PS C:\Users\AME\Documents\Digit_OCR> pip
- Assistant
The
fetch_mldatafunction has been deprecated and removed from scikit-learn. It was used to fetch datasets from the mldata.org repository, which is no longer active.As of scikit-learn 0.20, the function to use is
fetch_openml, which can be used to fetch datasets from the OpenML repository. Here's an example of fetching the MNIST dataset usingfetch_openml:from sklearn.datasets import fetch_openml mnist = fetch_openml('mnist_784', version=1) X, y = mnist["data"], mnist["target"]Please replace
fetch_mldatawithfetch_openmlin your code and adjust your code accordingly.If you get an ImportError, it might be because your scikit-learn version is out of date. To update scikit-learn, you can use pip from your terminal or command prompt:
pip install --upgrade scikit-learnMake sure you are using the correct pip command for your Python installation, which may involve using
pip3instead ofpipif you are on a system where Python 2 is still the default (though this is becoming increasingly rare), or ensuring you are using the pip associated with the Python interpreter you want to upgrade the library for. - User
json_data = _get_json_content_from_openml_api( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\AME\AppData\Local\Programs\Python\Python311\Lib\site-packages\sklearn\datasets_openml.py", line 254, in _get_json_content_from_openml_api raise OpenMLError(error_message) sklearn.datasets._openml.OpenMLError: No active dataset mnist-original found.
- Assistant
The error message
"No active dataset mnist-original found"indicates that the dataset with the name'mnist-original'could not be found on OpenML. It's possible that the name or version specified is outdated or incorrect.To resolve the error, you should make sure that you are using the correct name and version of the dataset. Let's try fetching the MNIST dataset using the correct identifier from OpenML:
from sklearn.datasets import fetch_openml # Fetch the MNIST dataset using its correct name 'mnist_784' and version 1 mnist = fetch_openml('mnist_784', version=1, as_frame=False) X, y = mnist['data'], mnist['target'] - User
- Assistant