Skip to Content
机器学习实战:基于Scikit-Learn、Keras 和TensorFlow (原书第2 版)
book

机器学习实战:基于Scikit-Learn、Keras 和TensorFlow (原书第2 版)

by Aurélien Géron
October 2020
Intermediate to advanced
693 pages
16h 26m
Chinese
China Machine Press
Content preview from 机器学习实战:基于Scikit-Learn、Keras 和TensorFlow (原书第2 版)
集成学习和随机森林
|
187
残差和树预测 集成预测
图 7-9 :在此梯度提升的描述中,第一个预测器(左上)进行正常训练,然后对每个连续的预
测器(左中和左下)针对先前预测器的残差进行训练。右列显示了集成的预测结果
超参数 learning_rate 对每棵树的贡献进行缩放。如果你将其设置为低值,比如 0.1,
则需要更多的树来拟合训练集,但是预测的泛化效果通常更好,这是一种被称为收缩的
正则化技术。图 7-10 显示了用低学习率训练的两个 GBRT 集成:左侧拟合训练集的树
数量不足,而右侧拟合训练集的树数量过多从而导致过拟合。
要找到树的最佳数量,可以使用提前停止法(参见第 4 章)。简单的实现方法就是使用
staged_predict() 方法:它在训练的每个阶段(一棵树时,两棵树时,等等)都对
集成的预测返回一个迭代器。以下代码训练了一个拥有 120 棵树的 GBRT 集成,然后测
量每个训练阶段的验证误差,从而找到树的最优数量,最后使用最优树数重新训练了一
个 GBRT 集成:
188
|
第
7
章
集成预测
图 7-10:GBRT 集成
—
预测器太少(左图)和预测器太多(右图)
import numpy as np
from sklearn.model_selection import
train_test_split ...
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

算法技术手册(原书第2 版)

算法技术手册(原书第2 版)

George T.Heineman, Gary Pollice, Stanley Selkow
管理Kubernetes

管理Kubernetes

Brendan Burns, Craig Tracey

Publisher Resources

ISBN: 9787111665977