Skip to Content
Python数据科学手册
book

Python数据科学手册

by Jake VanderPlas
January 2018
Intermediate to advanced
470 pages
13h 23m
Chinese
Posts & Telecom Press
Content preview from Python数据科学手册
326
|
第
5
章
方差也变大了(对比训练得分与验证得分的差异即可看出)。如果我们为复杂度更高的模
型继续增加训练数据,那么学习曲线最终也会收敛。
为模型和数据集画出学习曲线,可以帮你找到正确的方向,不断改进学习的效果。
5.3.4
 验证实践
:
网格搜索
前面的内容已经让我们对偏差与方差的均衡有了直观的认识,它们与模型的复杂度和训练
集的大小有关。在实际工作中,模型通常会有多个得分转折点,因此验证曲线和学习曲线
的图形会从二维曲线变成多维曲面。这种高维可视化很难展现,因此从图中找出验证得分
的最大值也不是一件简单的事。
Scikit-Learn
在 grid_search 提供了一个自动化工具解决这个问题。下面是用网格搜索寻找
最优多项式回归模型的示例。我们将在模型特征的三维网格中寻找最优值——包括多项式
的次数的搜索范围、回归模型是否拟合截距,以及回归模型是否需要进行标准化处理。我
们可以用
Scikit-Learn
的 GridSearchCV 元评估器来设置这些参数:
In[18]: from sklearn.grid_search import GridSearchCV
param_grid = {'polynomialfeatures__degree': np.arange(21),
'linearregression__fit_intercept': [True, False],
'linearregression__normalize': [True, False]}
grid = GridSearchCV(PolynomialRegression(), ...
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

Luciano Ramalho
Python数据分析基础

Python数据分析基础

Clinton W. Brownley
Python数据处理

Python数据处理

Jacqueline Kazil, Katharine Jarmul

Publisher Resources

ISBN: 9787115475893