惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Martin Fowler
Martin Fowler
V
Visual Studio Blog
有赞技术团队
有赞技术团队
T
Tailwind CSS Blog
B
Blog
I
InfoQ
博客园 - 三生石上(FineUI控件)
阮一峰的网络日志
阮一峰的网络日志
F
Fortinet All Blogs
H
Help Net Security
博客园 - Franky
宝玉的分享
宝玉的分享
博客园 - 司徒正美
C
Check Point Blog
G
Google Developers Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Jina AI
Jina AI
T
The Blog of Author Tim Ferriss
MongoDB | Blog
MongoDB | Blog
云风的 BLOG
云风的 BLOG
A
About on SuperTechFans
罗磊的独立博客
大猫的无限游戏
大猫的无限游戏
IT之家
IT之家

晚花行乐

马克卡尼在2026年达沃斯论坛上的讲话(阅读材料) | 晚花行乐 鸡娃如何用力才是恰到好处 | 晚花行乐 读万卷书,行万里路的辩证关系 | 晚花行乐 反对培训机构掐尖招生 | 晚花行乐 小泽和建国会谈最后10分钟全文(阅读材料) | 晚花行乐 来看看 DeepSeek 怎么鸡娃 | 晚花行乐 谈谈基本功 | 晚花行乐 惠普 ProDesk SFF PC 各系列参数对比 | 晚花行乐 解决瘦客户机上安装 Debian 12 启动失败问题 | 晚花行乐 意拾喻言:老外写的文言文 | 晚花行乐 笠翁对韵中的典故(十三元) | 晚花行乐 谈谈中考取消四小门 | 晚花行乐 亚马逊云科技产品免费试用攻略(3) - 对象存储服务 | 晚花行乐 在 Windows 10 LTSC 版本上安装 WSL2 | 晚花行乐 Debian 12 的常用配置项 | 晚花行乐 在 Debian 12 上安装 Nvidia 显卡驱动程序 | 晚花行乐 解决 Debian 12 关机失败问题 | 晚花行乐 解决 VS Code 自动更新版本后卡在连接界面 | 晚花行乐 观看巴黎奥运会有感 | 晚花行乐 在 Windows10 上安装惠普旧打印机驱动程序 | 晚花行乐 欢迎关注公众号:晚花行乐 | 晚花行乐 如何编写拼写检查器 | 晚花行乐 亚马逊云科技产品免费试用攻略(2) - 云服务器 | 晚花行乐 Pandas 中 axis 参数的理解(附实例) | 晚花行乐 我打算命个名,叫什么什么 Manager | 晚花行乐 上海武康路历史建筑一览 | 晚花行乐 Python 实现简单的数学表达式解析并处理 | 晚花行乐 观看马拉松的感悟 | 晚花行乐 Python 保存 Cookies 到文件并再次读取 | 晚花行乐 如何为 Hugo 静态网站添加评论功能 | 晚花行乐
Scikit-learn 学习笔记(2)数据集 | 晚花行乐
2022-08-04 · via 晚花行乐

这个系列是我通过阅读 Scikit-learn 的文档,结合自己的理解和掌握的知识,重新把文档描述出来。希望能加深自己的理解,希望能帮到有需要的人。

学习材料:https://scikit-learn.org/stable/tutorial/statistical_inference/index.html

数据集

Scikit-learn 能处理的数据集都必须是2维矩阵,第一维是列举了所有的观察值,第二维则是每个观察值的多个特征(比如下面矩阵中的 $f_n$ 就是每个数据样本的第 $n$ 个特征)。

$$ \underbrace{ \begin{bmatrix} \begin{pmatrix} f_1 \\ f_2 \\ f_3 \\ f_4 \\ \end{pmatrix} & \begin{pmatrix} f_1 \\ f_2 \\ f_3 \\ f_4 \\ \end{pmatrix} & \begin{pmatrix} f_1 \\ f_2 \\ f_3 \\ f_4 \\ \end{pmatrix} & \cdots \begin{pmatrix} f_1 \\ f_2 \\ f_3 \\ f_4 \\ \end{pmatrix} & \end{bmatrix}}_{\text{samples}} $$

Scikit-learn 自带的 iris 数据(鸢尾花数据集),它包含了150个样本,每个样本体现了4方面特征,是一个 $150 \times 4$ 的二维矩阵。

>>> from sklearn import datasets
>>> iris = datasets.load_iris()
>>> iris.data.shape
(150, 4)
>>> iris.data[:10]
array([[5.1, 3.5, 1.4, 0.2],
       [4.9, 3. , 1.4, 0.2],
       [4.7, 3.2, 1.3, 0.2],
       [4.6, 3.1, 1.5, 0.2],
       [5. , 3.6, 1.4, 0.2],
       [5.4, 3.9, 1.7, 0.4],
       [4.6, 3.4, 1.4, 0.3],
       [5. , 3.4, 1.5, 0.2],
       [4.4, 2.9, 1.4, 0.2],
       [4.9, 3.1, 1.5, 0.1]])
>>>

库里自带了对数据的描述,摘录如下:

Iris plants dataset

Data Set Characteristics:

:Number of Instances: 150 (50 in each of three classes)
:Number of Attributes: 4 numeric, predictive attributes and the class
:Attribute Information:
    - sepal length in cm
    - sepal width in cm
    - petal length in cm
    - petal width in cm
    - class:
            - Iris-Setosa
            - Iris-Versicolour
            - Iris-Virginica

:Summary Statistics:

============== ==== ==== ======= ===== ====================
                Min  Max   Mean    SD   Class Correlation
============== ==== ==== ======= ===== ====================
sepal length:   4.3  7.9   5.84   0.83    0.7826
sepal width:    2.0  4.4   3.05   0.43   -0.4194
petal length:   1.0  6.9   3.76   1.76    0.9490  (high!)
petal width:    0.1  2.5   1.20   0.76    0.9565  (high!)
============== ==== ==== ======= ===== ====================

:Missing Attribute Values: None
:Class Distribution: 33.3% for each of 3 classes.
:Creator: R.A. Fisher
:Donor: Michael Marshall (MARSHALL%PLU@io.arc.nasa.gov)
:Date: July, 1988

The famous Iris database, first used by Sir R.A. Fisher. The dataset is taken from Fisher’s paper. Note that it’s the same as in R, but not as in the UCI Machine Learning Repository, which has two wrong data points.

This is perhaps the best known database to be found in the pattern recognition literature. Fisher’s paper is a classic in the field and is referenced frequently to this day. (See Duda & Hart, for example.) The data set contains 3 classes of 50 instances each, where each class refers to a type of iris plant. One class is linearly separable from the other 2; the latter are NOT linearly separable from each other.

鸢尾花数据集

著名的鸢尾花数据集,由英国统计与遗传学家 R.A. Fisher 爵士首次提出。现今是模式识别领域中最知名的数据集。这个数据集包括来自三种鸢尾花:

  • Iris Setosa(山鸢尾)

  • Iris Versicolour(杂色鸢尾)

  • Iris Virginica(维吉尼亚鸢尾)

150 朵鸢尾花的数据来自以上三种每种 50 朵。每条数据描述花的4个特征:4个特征(花萼长度,花萼宽度,花瓣长度,花瓣宽度),都量化为数字形式。

三种花的数据中,其中有一种数据可以以线性分类的方法区分出来,但是另外两种则不能线性相互拆分开。

估计器

Scikit-learn 自带多种的估计器,用来完成机器学习的各种任务:

估计器的输入是原始的数据(raw data),根据估计器任务类型的不同,输出的结果可能是分类的标签、回归的参数、聚类的结果。

所有的估计器都有 .fit() 接口用于输入数据、学习数据。

如果要给估计器设定参数,可以在实例化的时候指定:

estimator = Estimator(param1=1, param2=2)
>>> estimator.param1
1

学习成果:

当数据集送入估计器的 .fit() 接口后,估计的参数就可以从估计器对象的属性读取得到。要注意的是,属性名称是以下划线结尾的。

>>> estimator.estimated_param_ 

各位读后有什么想法,请在下方留言吧!如果对本文有疑问或者寻求合作,欢迎 联系邮箱邮箱已到剪贴板

精彩评论