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 版)
74
|
第
2
章
不使用转换器的情况下,如果你要删除列,则可以指定字符串 "drop"。如
果你希望这些列保持不变,也可以指定 "pass through"。默认情况下,其
余列(即未列出的列)将被删除。如果你希望以不同方式处理这些列,则可以
将 remainder 这个超参数设置为任意转换器(或 "passthrough")。
如果你使用的是 Scikit-Learn 0.19 或更早版本,则可以使用第三方库,例如 sklearn-
pandas,或者可以推出自己的自定义转换器来获得和 ColumnTransformer 相同的功
能。另外,你可以使用 FeatureUnion 类,该类可以应用于不同的转换器并合并其输
出。但是你不能为每个转换器指定不同的列,它们都适用于整个数据。你也可以使用针
对列的自定义转换器来解决这个限制(有关示例,请参见 Jupyter notebook)。
2.6 选择和训练模型
至此,你提出了问题,获得了数据,也进行了数据探索,然后对训练集和测试集进行了
抽样并编写了转换流水线,从而可以自动清理和准备机器学习算法的数据!现在是时候
选择机器学习模型并展开训练了。
2.6.1 训练和评估训练集
好消息是,在经过前面的步骤之后,事情现在变得比想象中容易很多。首先,如同我们
在第 1 章所做的,先训练一个线性回归模型:
from sklearn.linear_model import
LinearRegression
lin_reg = LinearRegression()
lin_reg.fit(housing_prepared, ...
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