当前位置:   article > 正文

sklearn中digits手写字体数据集_digits数据集

digits数据集

1. 导入

  1. from sklearn import datasets
  2. digits = datasets.load_digits()

2. 属性查看

  • digits: bunch类型
  1. print(digits.keys())
  2. dict_keys(['data', 'target', 'target_names', 'images', 'DESCR'])

3. 具体数据

  • 1797个样本,每个样本包括8*8像素的图像和一个[0, 9]整数的标签

3.1 images

  • ndarray类型,保存8*8的图像,里面的元素是float64类型,共有1797张图片
  • 用于显示图片
    1. import matplotlib.pyplot as plt
    2. plt.imshow(digits.images[0])
    3. <matplotlib.image.AxesImage at 0x1676ca13ba8>
    4. plt.show()
  •  

 

  1. # 获取第一张图片
  2. print(digits.images[0])
  3. [[ 0. 0. 5. 13. 9. 1. 0. 0.]
  4. [ 0. 0. 13. 15. 10. 15. 5. 0.]
  5. [ 0. 3. 15. 2. 0. 11. 8. 0.]
  6. [ 0. 4. 12. 0. 0. 8. 8. 0.]
  7. [ 0. 5. 8. 0. 0. 9. 8. 0.]
  8. [ 0. 4. 11. 0. 1. 12. 7. 0.]
  9. [ 0. 2. 14. 5. 10. 12. 0. 0.]
  10. [ 0. 0. 6. 13. 10. 0. 0. 0.]]
  • 或者

    1. from skimage import io
    2. im=plt.imshow(digits.images[0])
    3. print(type(im))
    4. <class 'matplotlib.image.AxesImage'>
    5. io.show()

 

3.2 data

  • ndarray类型,将images按行展开成一行,共有1797行
  • 输入数据
    1. print(digits.data[0])
    2. [ 0. 0. 5. 13. 9. 1. 0. 0. 0. 0. 13. 15. 10. 15. 5.
    3. 0. 0. 3. 15. 2. 0. 11. 8. 0. 0. 4. 12. 0. 0. 8.
    4. 8. 0. 0. 5. 8. 0. 0. 9. 8. 0. 0. 4. 11. 0. 1.
    5. 12. 7. 0. 0. 2. 14. 5. 10. 12. 0. 0. 0. 0. 6. 13.
    6. 10. 0. 0. 0.]

3.3 target

  • ndarray类型,指明每张图片的标签,也就是每张图片代表的数字
  • 输出数据,标签
    1. print(digits.target[0])
    2. 0

    3.4 target_names

  • ndarray类型,数据集中所有标签值
    1. print(digits.target_names)
    2. [0 1 2 3 4 5 6 7 8 9]

    3.5 DESCR

  • 数据集的描述,作者,数据来源等
    1. print(digits.DESCR)
    2. .. _digits_dataset:
    3. Optical recognition of handwritten digits dataset
    4. --------------------------------------------------
    5. **Data Set Characteristics:**
    6. :Number of Instances: 5620
    7. :Number of Attributes: 64
    8. :Attribute Information: 8x8 image of integer pixels in the range 0..16.
    9. :Missing Attribute Values: None
    10. :Creator: E. Alpaydin (alpaydin '@' boun.edu.tr)
    11. :Date: July; 1998
    12. This is a copy of the test set of the UCI ML hand-written digits datasets
    13. http://archive.ics.uci.edu/ml/datasets/Optical+Recognition+of+Handwritten+Digits
    14. The data set contains images of hand-written digits: 10 classes where
    15. each class refers to a digit.
    16. Preprocessing programs made available by NIST were used to extract
    17. normalized bitmaps of handwritten digits from a preprinted form. From a
    18. total of 43 people, 30 contributed to the training set and different 13
    19. to the test set. 32x32 bitmaps are divided into nonoverlapping blocks of
    20. 4x4 and the number of on pixels are counted in each block. This generates
    21. an input matrix of 8x8 where each element is an integer in the range
    22. 0..16. This reduces dimensionality and gives invariance to small
    23. distortions.
    24. For info on NIST preprocessing routines, see M. D. Garris, J. L. Blue, G.
    25. T. Candela, D. L. Dimmick, J. Geist, P. J. Grother, S. A. Janet, and C.
    26. L. Wilson, NIST Form-Based Handprint Recognition System, NISTIR 5469,
    27. 1994.
    28. .. topic:: References
    29. - C. Kaynak (1995) Methods of Combining Multiple Classifiers and Their
    30. Applications to Handwritten Digit Recognition, MSc Thesis, Institute of
    31. Graduate Studies in Science and Engineering, Bogazici University.
    32. - E. Alpaydin, C. Kaynak (1998) Cascading Classifiers, Kybernetika.
    33. - Ken Tang and Ponnuthurai N. Suganthan and Xi Yao and A. Kai Qin.
    34. Linear dimensionalityreduction using relevance weighted LDA. School of
    35. Electrical and Electronic Engineering Nanyang Technological University.
    36. 2005.
    37. - Claudio Gentile. A New Approximate Maximal Margin Classification
    38. Algorithm. NIPS. 2000.


                        
        
         
            
                            
                    
     

 

 

 

 

 

 

 

声明:本文内容由网友自发贡献,转载请注明出处:【wpsshop】
推荐阅读
相关标签
  

闽ICP备14008679号