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数据科学手册
机器学习
|
371
显然,在一些区域,两棵树产生了一致的结果(例如
4
个角上);而在另一些区域,两棵
树的分类结果差异很大(例如两类接壤的区域)。不一致往往都发生在分类比较模糊的地
方,因此假如将
两棵
树的结果组合起来,可能就会获得更好的结果!
如果你正在运行
Notebook
,可以用下面的函数交互地浏览决策树对数据随机子集训练的结
果(如图
5-73
所示):
In[7]: # helpers_05_08.py文件位于在线附录
# (https://github.com/jakevdp/PythonDataScienceHandbook)
import helpers_05_08
helpers_05_08.randomized_tree_interactive(X, y)
图 5-73:交互式随机决策树组件的第一帧画面,完整内容请参见在线附录
就像用两棵决策树的信息改善分类结果一样,我们可能想用更多决策树的信息来改善分类
结果。
5.8.2
 评估器集成算法
:
随机森林
通过组合多个过拟合评估器来降低过拟合程度的想法其实是一种集成学习方法,称为
装袋
算法
。装袋算法使用并行评估器对数据进行有放回抽取集成(也可以说是大杂烩),每个
评估器都对数据过拟合,通过求均值可以获得更好的分类结果。随机决策树的集成算法就
是
随机森林
。
我们可以用
Scikit-Learn
的 BaggingClassifier 元评估器来实现这种装袋分类器(如图
5-74
所示):
In[8]: from sklearn.tree import DecisionTreeClassifier ...
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