from sklearn.datasets import fetch_openml
mnist = fetch_openml('mnist_784')
In [6]:
X, y =mnist['data'], mnist['target'] X.shape
Out[6]:
(70000, 784)
In [10]:
y.shape X.index
Out[10]:
RangeIndex(start=0, stop=70000, step=1)
In [30]:
%matplotlib inline
import matplotlib
import matplotlib.pyplot as plt
some_digit = X.loc[36011].values
print(type(some_digit))
some_digit_image = some_digit.reshape(28, 28)
plt.imshow(some_digit_image, cmap = matplotlib.cm.binary, interpolation="nearest")
plt.axis("off")
plt.show()
<class 'numpy.ndarray'>

In [32]:
y[36011]
Out[32]:
'5'
In [45]:
X_train,

文章展示了如何从sklearn.datasets导入MNIST数据集,对数据进行预处理,然后使用SGDClassifier进行训练并评估模型性能。通过交叉验证方法调整模型,并比较了不同分类器的预测准确性。
最低0.47元/天 解锁文章

1万+

被折叠的 条评论
为什么被折叠?



