Skip to Content
面向数据科学家的实用统计学
book

面向数据科学家的实用统计学

by Peter Bruce, Andrew Bruce
October 2018
Beginner to intermediate
238 pages
6h 32m
Chinese
Posts & Telecom Press
Content preview from 面向数据科学家的实用统计学
统计机器学习
|
189
λ
的值决定了系数被惩罚的程度。由较大的值所生成的模型不太可能过拟合数据。
Lasso
回归与此类似,只是其惩罚项使用的是曼哈顿距离,而非欧氏距离:
2
0 1 1
1
ˆ ˆ ˆ ˆ ˆ
( ) (| | | |)
n
i i p p
i
Y b b X bX b b
α
=
− − − − + + +
∑
前面介绍的
xgboost
参数
lambda
和
alpha
具有类似的作用。
6.4.4
 超参数和交叉验证
xgboost 函数具有一组令人望而却步的超参数,相关介绍可参见本节的知识点“
XGBoost
超参数”。正如
6.4.3
节中介绍的,特定的参数选择可以显著地改进模型拟合。鉴于超参数
有大量的组合,我们应该如何从中做出选择呢?这个问题的标准解决方案是使用
交叉验
证
,参见
4.2.3
节。交叉验证将数据随机拆分为
K
个不同的组,也被称为
K
折。对于每折,
交叉验证使用非折内数据训练模型,然后使用折内数据评估模型。这为模型在样本外数据
上的正确率提供了一种度量。最佳的一组超参数可以由总体误差最低的模型给出,总体误
差是通过对每折的误差取平均计算得到的。
为了介绍这一技术,我们将其应用于
xgboost
函数的参数选择。在本例中,我们使用了两个
参数:收缩参数
eta
(参见
6.4.2
节)和表示树模型最大深度的参数
max_depth
。
max_depth
定义了叶节点到树根的最大深度,默认值为
6
。这提供了另一种控制过拟合的方式,即层数
更多的树模型往往更为复杂,并可能会过拟合数据。首先,我们设置折数和参数列表。
> N <- nrow(loan_data) ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

基于Python的智能文本分析

基于Python的智能文本分析

Benjamin Bengfort, Rebecca Bilbro, Tony Ojeda
Python数据处理

Python数据处理

Jacqueline Kazil, Katharine Jarmul
精通機器學習

精通機器學習

Aurélien Géron
C++语言导学(原书第2版)

C++语言导学(原书第2版)

本贾尼 斯特劳斯特鲁普

Publisher Resources

ISBN: 9787115493668