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 版)
分类
|
107
3.8 练习题
1. 为 MNIST 数据集构建一个分类器,并在测试集上达成超过 97% 的准确率。提示:
KNeighborsClassifier 对这个任务非常有效,你只需要找到合适的超参数值即
可(试试对 weights 和 n_neighbors 这两个超参数进行网格搜索)。
2. 写一个可以将 MNIST 图片向任意方向(上、下、左、右)移动一个像素的功能
注 5
。
然后对训练集中的每张图片,创建四个位移后的副本(每个方向一个),添加到训练
集。最后,在这个扩展过的训练集上训练模型,测量其在测试集上的准确率。你应
该能注意到,模型的表现甚至变得更好了!这种人工扩展训练集的技术称为数据增
广或训练集扩展。
1
3. Kaggle 上非常棒的起点:处理泰坦尼克(Titanic)数据集。
4. 创建一个垃圾邮件分类器(更具挑战性的练习):
•
从 Apache SpamAssassin 的公共数据集中下载垃圾邮件和非垃圾邮件。
•
解压数据集并熟悉数据格式。
•
将数据集分为训练集和测试集。
•
写一个数据准备的流水线将每封邮件转换为特征向量。你的流水线应将电子邮
件转换为一个“指示出所有可能的词存在与否”的(稀疏)向量。比如,如果所
有的邮件都只包含四个词“ Hello”“ how”“ are”“ you”,那么邮件“ Hello you
Hello Hello you”会被转换成为向量 [1,0,0,1](意思是“Hello”存在,“how”
不存在,“ are”不存在,“ you”存在
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