Python机器学习(二十七)Sklearn数据集基本信息
前面章节中,我们加载了SciKit-Learn自带的数据集digits,可以通过以下语句查看数据集中包含哪些主要内容: digits.keys()
输出 dict_keys(["data", "target", "target_names", "images", "DESCR"])data 样本数据 target 目标值 target_names 目标名称 images 图像格式(二维)的样本数据 DESCR 描述信息
查看数据集的描述: print(digits.DESCR)
输出 .. _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 pided 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.
这是一个手写数字的数据集。
类似地,你也可以查看其它内容: .. _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 pided 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.
注意:如果使用read_csv()导入数据集,数据集已经分割好,导入的数据集中可能没有描述字段,但是你可以使用head()或tail()来检查数据。在这种情况下,最好仔细查看数据描述文件夹!
接下来,我们进一步了解数据集中的数据。
可以看到,数据集中的数据都是numpy数组的格式,可以查看这些数组的数据类型,形状,长度等信息。 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
可以看出,digits.data中,有1797个样本,每个样本有64个特征值(实际上是像素灰度值)。
digits.target中,包含了上面样本数据对应的目标值(样本标签),同样有1797个目标值,但10个唯一值,即0-9。换句话说,所有1797个目标值都由0到9之间的数字组成,这意味着模型要识别的是从0到9的数字。
digits.target_names包含了样本标签的名称: 0~9。
最后,可以看到digits.images数组包含3个维度: 有1797个实例,大小为8 8像素。digits.images数据与digits.data内容应该相同,只是格式不同。可以通过以下方式验证两者内容是否相同: print(np.all(digits.images.reshape((1797, 64)) == digits.data)) # 输出:true
把digits.images改变形状为(1797, 64),与digits.data比较,两者相等。numpy方法all()可以检测所有数组元素的值是否为True。
Centos7安装Nginx安装所需环境一。gcc安装安装nginx需要先将官网下载的源码进行编译,编译依赖gcc环境,如果没有gcc环境,则需要安装yuminstallgccc二。PCREpcredevel
文件公示!宝马中国全资收购华晨中华工厂10月20日,国家市场监管总局反垄断局网站公示宝马(中国)投资有限公司收购华晨汽车制造有限公司股权案。文件显示,华晨汽车集团控股有限公司(华晨集团)目前持有华晨汽车制造有限公司(华
家园系统新篇章?继诛仙后的又一新作继诛仙之后,仙侠手游的炸街之作诛仙手游,延续端游高质量场景人设玩法等设计,让手游玩家能在重温IP情怀之余,体验到制作精良的3D仙侠手游。从大话西游到仙剑奇侠传,不难看出,仙侠IP的
又一大作延迟EA官宣战地2042跳票战地2042应该算是今年下半年最受玩家期待的游戏之一,此前该作官方确定的发售时间是10月23日,但是在今天EA官方宣布了该作将会跳票到11月19日正式发售,想必很多玩家们都感到无奈
不念西风独自凉,光影潋滟夜未央君看,光影潋滟夜未央浮华似影,沧海如烟,蓦然惊梦,往事难重省。灯火明灭,不晓西风情深,君看,光影潋滟夜未央文冰馨雪馥深冬,夜风很凉,却让人分外清醒。灯火照耀之处,似明非明。借着微光
挑战和希望并存,自动驾驶离我们究竟还有多远?近日,小米集团发布的Q2财务报告显示,小米已与自动驾驶技术公司DeepMotion的相关方达成股份购买协议,将以7737万美元(约人民币5亿元)整体收购DeepMotion。Dee
暗黑2重制版NS版最新截图公开,画面质量不错近日暗黑官方公布了暗黑破坏神2重制版主机版本已经开放预载,该作将会在本月的23日晚上11点正式开放游戏,之后PC版游戏的预载也会开放,所以PC玩家不用着急。暗黑破坏神2重制版将会在
以色列军队惊现隐身衣,开启魔法世界的真人秀7月20日21时,蓝色起源创始人贝索斯率先完成太空旅行,让科幻变成了现实。然而让科幻成真的不止是太空旅行,拥有隐形功能的TVC更让科技圈为之震颤。TVC,全称ThermoVisua
如何正确撸拼多多羊毛拼多多可以撸的东西很多今天给大家带来一个简单红包助力,这个相信很多人都知道,不过这东西是有方法的,你如果没有方法可能会被反撸。接下来我就把我知道的方法告诉给大家快速获得拼多多100
年轻人口中的的b站正在脱离二次元大家好,我是在头条快一个月赚了不到5毛钱的人,我们今天来聊一下哔哩哔哩(简称b站)百度百科有点地方错了,09年那会还不叫b站叫mikufans而在10年才改名成bilibili。在
让未成年人过早接触网络好吗?前几天回了一个话题是关于未成年人沉迷网络游戏,很多人都表示网络游戏对于未成年来说影响最大,不知道怎么办才好。那晚接触网络会改变现状吗?我在初中的时候,学校不让带手机,同学们嫌无聊带