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 版)
146
|
第
5
章
与 Logistic 回归分类器不同,SVM 分类器不会输出每个类的概率。
我们可以将 SVC 类与线性内核一起使用,而不使用 LinearSVC 类。创建 SVC 模型时,我
们可以编写 SVC(kernel = "linear", C = 1)。或者我们可以将 SGDClassifier 类与
SGDClassifier(loss="hinge", alpha=1/(m*C)) 一起使用。这将使用常规的
随机梯度下降(见第 4 章)来训练线性 SVM 分类器。它的收敛速度不如 LinearSVC
类,但是对处理在线分类任务或不适合内存的庞大数据集(核外训练)很有用。
LinearSVC 类会对偏置项进行正则化,所以你需要先减去平均值,使训练
集居中。如果使用 StandardScaler 会自动进行这一步。此外,请确保超
参数 loss 设置为 "hinge",因为它不是默认值。最后,为了获得更好的性
能,还应该将超参数 dual 设置为 False,除非特征数量比训练实例还多(本
章后文将会讨论)。
5.2 非线性 SVM 分类
虽然在许多情况下,线性 SVM 分类器是有效的,并且通常出人意料的好,但是,有很
多数据集远不是线性可分离的。处理非线性数据集的方法之一是添加更多特征,比如多
项式特征(如第 4 章所述)。某些情况下,这可能导致数据集变得线性可分离。参见图 5-5
的左图:这是一个简单的数据集,只有一个特征
x
1
。可以看出,数据集线性不可分。但
是如果添加第二个特征
x
2
= ( ...
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