手寫數字數據集(下載地址: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)
(未完待續)