SciKit-Learn dataset's information

All rights reserved ## reserved, reprint indicate the source

chapter


In the previous section, we loaded SciKit-Learn comes with a data set digits, you can view the dataset What are the main contents include the following statement:

digits.keys()

Export

dict_keys(['data', 'target', 'target_names', 'images', 'DESCR'])
  • data sample
  • target Target value
  • target_names Target Name
  • images Image format (two-dimensional) data sample
  • DESCR Description

View dataset description:

print(digits.DESCR)

Export

.. _digits_dataset:

Optical recognition of handwritten digits dataset
--------------------------------------------------

**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 '@' boun.edu.tr)
    :Date: July; 1998

This is a copy of the test set of the UCI ML hand-written digits datasets
https://archive.ics.uci.edu/ml/datasets/Optical+Recognition+of+Handwritten+Digits

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
distortions.

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,
1994.

.. topic:: References

  - 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.
    2005.
  - Claudio Gentile. A New Approximate Maximal Margin Classification
    Algorithm. NIPS. 2000.

This is a handwritten numeral data set.

Similarly, you can also view other content:


# 打印数据内容
print(digits.data)

# 打印目标值
print(digits.target)

# 打印目标名称(标签)
print(digits.target_names)
...

Note : If you use the read_csv()import data, data sets, have been divided good, imported data may not be focused on the description field, but you can use head()or tail()to check the data. In this case, better check the data describing folder!

Next, we learn more about the data in the dataset.

Can be seen, the data format of the data set is numpy array, these arrays can view the data type, shape, length and other information.

import numpy as np

# 打印data数组的形状
print(digits.data.shape) # 输出:(1797, 64)
# 打印data数组的类型
print(digits.data.dtype) # 输出:float64

# 打印target数组的形状
print(digits.target.shape) # 输出:(1797,)
# 打印target数组的类型
print(digits.target.dtype) # 输出:int32
# 打印target数组中包含的唯一值数量
print(len(np.unique(digits.target))) # 输出:10

# 打印target_names数组的形状
print(digits.target_names.shape) # 输出:(10,)
# 打印target_names数组的类型
print(digits.target_names.dtype) # 输出:int32

# 打印images数组的形状
print(digits.images.shape) # 输出:(1797, 8, 8)
# 打印images数组的类型
print(digits.images.dtype) # 输出:float64

It can be seen digits.data, there are 1797 samples per sample eigenvalues 64 (actually, the pixel gray value).

digits.target, The target contains (sample labels) corresponding to the above sample data, the same target value of 1797, but the 10 unique values, i.e., 0-9. In other words, all of the target 1797 by the numbers 0 to 9 that, which means that the model is to be identified from 0 to 9, inclusive.

digits.target_namesSample contains a tag name: 0-9.

Finally, you can see digits.imagesthe array contains three dimensions: Example 1 797 has a size of 8 × 8 pixels. digits.imagesData digits.datacontent should be the same, but in different formats. Both can verify whether the contents of the same in the following ways:

print(np.all(digits.images.reshape((1797, 64)) == digits.data)) # 输出:true

The digits.imageschanging shape (1797, 64), and digits.datacomparison, the two are equal. numpy method all()can detect whether the values of all array elements to True.

Guess you like

Origin www.cnblogs.com/haibianren/p/11864606.html
Recommended