Skip to Content
精通機器學習
book

精通機器學習

by Aurélien Géron
April 2020
Intermediate to advanced
816 pages
18h 32m
Chinese
GoTop Information, Inc.
Content preview from 精通機器學習
178
|
第六章:決策樹
其他演算法的做法是先不施加限制地訓練決策樹
修剪
刪除
沒必要
的節點
如果一個節點的子節點都是葉節點
而且它對於純度的改善在統
計上不明顯
它就是沒必要的
我們通常用標準統計檢定
例如
χ
2
檢定
卡方檢定
),
來估計
純度的改善純粹只是偶然的結果
的機率
稱為
虛無假設
null hypothesis))。
如果這個機率
稱為
p-value
高於某個閾值
通常是
5%
用超參數來控制
),
那麼該節點就被視為沒必要的
它的子
節點都會被刪除
這個修剪動作會一直做到所有沒必要的節點都被刪除為
6-3
是用
moons
資料組
見第
5
來訓練的兩個決策樹
左邊的決策樹是用內定的超
參數來訓練的
也就是不限制
),
右邊是用
min_samples_leaf=4
來訓練的
顯然左邊的模
型過擬了
右邊的模型或許有更好的類推能力
無限制
6-3 
使用
min_samples_leaf
來正則化
回歸
決策樹也可以執行回歸任務
我們用
Scikit-Learn
DecisionTreeRegressor
類別來建立一
個回歸樹
用有雜訊的二次資料組以及
max_depth=2
來訓練它
from sklearn.tree import
DecisionTreeRegressor
tree_reg = DecisionTreeRegressor(max_depth=2)
tree_reg.fit(X, y)
6-4
是產生的樹
回歸
|
179
6-4 
回歸決策樹
這棵樹看起來很像之前建立的分類樹
它們主要的差異在於 ...
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

下一代空间计算:AR与VR创新理论与实践

下一代空间计算:AR与VR创新理论与实践

Erin Pangilinan, Steve Lukas, Vasanth Mohan
C语言核心技术(原书第2版)

C语言核心技术(原书第2版)

Peter Prinz, Tony Crawford

Publisher Resources

ISBN: 9789865024345