机器学习:手写数字数据集

手写数字数据集(下载地址:http://www.cs.nyu.edu/~roweis/data.html

  手写数字数据集包括1797个0-9的手写数字数据,每个数字由8*8大小的矩阵构成,矩阵中值的范围是0-16,代表颜色的深度。
  使用sklearn.datasets.load_digits即可加载相关数据集。

参数:
* return_X_y:若为True ,则以(data, target)形式返回数据;默认为False,表示以字典形式返回数据全部信息(包括data和target)。
* n_class:表示返回数据的类别数,如:n_class = 5, 则返回0到4的数据样本。

加载数据:

>>> from sklearn.datasets import load_digits
>>> digits = load_digits()
>>> print(digits.data.shape)
>>> print(digits.target.shape)
>>> print(digits.images.shape)

>>> import matplotlib.pyplot as plt
>>> plt.matshow(digits.images[0])
>>> plt.show()

输出:

(1797L, 64L)
(1797L,)
(1797L, 8L, 8L)

(未完待续)



原文地址:https://www.cnblogs.com/wjunneng/p/7325112.html