機器學習資料集/ 範例一: The digits dataset



#這行是在ipython notebook的介面裏專用,如果在其他介面則可以拿掉
%matplotlib inline
from sklearn import datasets

import matplotlib.pyplot as plt

digits = datasets.load_digits()

plt.figure(1, figsize=(3, 3))
plt.imshow(digits.images[-1],, interpolation='nearest')



digits = datasets.load_digits() 將一個dict型別資料存入digits,我們可以用下面程式碼來觀察裏面資料

for key,value in digits.items() :
        print (key,value.shape)
        print (key)
('images', (1797L, 8L, 8L))
('data', (1797L, 64L))
('target_names', (10L,))
('target', (1797L,))
顯示 說明
('images', (1797L, 8L, 8L)) 共有 1797 張影像,影像大小為 8x8
('data', (1797L, 64L)) data 則是將8x8的矩陣攤平成64個元素之一維向量
('target_names', (10L,)) 說明10種分類之對應 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
DESCR 資料之描述
('target', (1797L,)) 記錄1797張影像各自代表那一個數字


images_and_labels = list(zip(digits.images,
for index, (image, label) in enumerate(images_and_labels[:4]):
    plt.subplot(2, 4, index + 1)
    plt.imshow(image,, interpolation='nearest')
    plt.title('Training: %i' % label)


Optical Recognition of Handwritten Digits Data Set

Data Set Characteristics:
    :Number of Instances: 5620
    :Number of Attributes: 64
    :Attribute Information: 8x8 image of integer pixels in the range 0..16.
    :Missing Attribute Values: None
    :Creator: E. Alpaydin (alpaydin '@'
    :Date: July; 1998

This is a copy of the test set of the UCI ML hand-written digits datasets

The data set contains images of hand-written digits: 10 classes where
each class refers to a digit.

Preprocessing programs made available by NIST were used to extract
normalized bitmaps of handwritten digits from a preprinted form. From a
total of 43 people, 30 contributed to the training set and different 13
to the test set. 32x32 bitmaps are divided into nonoverlapping blocks of
4x4 and the number of on pixels are counted in each block. This generates
an input matrix of 8x8 where each element is an integer in the range
0..16. This reduces dimensionality and gives invariance to small

For info on NIST preprocessing routines, see M. D. Garris, J. L. Blue, G.
T. Candela, D. L. Dimmick, J. Geist, P. J. Grother, S. A. Janet, and C.
L. Wilson, NIST Form-Based Handprint Recognition System, NISTIR 5469,

  - C. Kaynak (1995) Methods of Combining Multiple Classifiers and Their
    Applications to Handwritten Digit Recognition, MSc Thesis, Institute of
    Graduate Studies in Science and Engineering, Bogazici University.
  - E. Alpaydin, C. Kaynak (1998) Cascading Classifiers, Kybernetika.
  - Ken Tang and Ponnuthurai N. Suganthan and Xi Yao and A. Kai Qin.
    Linear dimensionalityreduction using relevance weighted LDA. School of
    Electrical and Electronic Engineering Nanyang Technological University.
  - Claudio Gentile. A New Approximate Maximal Margin Classification
    Algorithm. NIPS. 2000.

這個描述檔說明了這個資料集是在 1998年時建立的,由E. Alpaydin, C. Kaynak ,Department of Computer Engineering Bogazici University, Istanbul Turkey 建立的。數字的筆跡總共來自43個人,一開始取像時為32x32的點陣影像,之後經運算處理形成 8x8影像,其中灰階記錄的範圍則為 0~16的整數。



results matching ""

    No results matching ""