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 版)
端到端的机器学习项目
|
71
和人均 GDP 来代替国家代码)。或者,你可以用可学习的低维向量(称为嵌
入)来替换每个类别。每个类别的表征可以在训练期间学习。这是表征学习
的示例(更多细节参见第 13 章和第 17 章 )。
2.5.3 自定义转换器
虽然 Scikit-Learn 提供了许多有用的转换器,但是你仍然需要为一些诸如自定义清理操
作或组合特定属性等任务编写自己的转换器。你当然希望让自己的转换器与 Scikit-Learn
自身的功能(比如流水线)无缝衔接,而由于 Scikit-Learn 依赖于鸭子类型的编译,而
不是继承,所以你所需要的只是创建一个类,然后应用以下三种方法:fit()(返回
self)、 transform()、fit_transform()。
你可以通过添加 TransformerMixin 作为基类,直接得到最后一种方法。同时,如果
添加 BaseEstimator 作为基类(并在构造函数中避免 *args 和 **kargs),你还能额外
获得两种非常有用的自动调整超参数的方法(get_params() 和 set_params())。
例如,我们前面讨论过的组合属性,这里有个简单的转换器类,用来添加组合后的
属性:
from sklearn.base import
BaseEstimator, TransformerMixin
rooms_ix, bedrooms_ix, population_ix, households_ix = 3, 4, 5, 6
class CombinedAttributesAdder ...
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