sklearn 的fetch mldata无法导入的解决办法

今日学习Hands-On Machine Learning with Scikit-Learn and TensorFlow 的第三章的时候需要导入MNIST 数据库,后来死活连不上远程服务器,结果发现,sklearn 0.20版本后不再提供fetch_mldata的数据下载。

#源代码
from sklearn.datasets import fetch_mldata
mnist = fetch_mldata('MNIST original')

最后通过官网发现,需要更改函数,修正方法:

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

或者:

from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets('MNIST_data', one_hot=True)

注意:
MNIST不再按照顺序排列,原来的X[36000]为5, 更新后的X[36000]为9。

参考:
https://scikit-learn.org/dev/modules/generated/sklearn.datasets.fetch_openml.html

https://github.com/ageron/handson-ml/issues/7

阅读量: | 柯西君_BingWong | 2018-11-13