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 版)
176
7
... clf.fit(X_train, y_train)
... y_pred = clf.predict(X_test)
...
print
(clf.__class__.__name__, accuracy_score(y_test, y_pred))
...
LogisticRegression 0.864
RandomForestClassifier 0.896
SVC 0.888
VotingClassifier 0.904
投票分类器略胜于所有单个分类器。
如果所有分类器都能够估算出类别的概率(即有 predict_proba() 方法),那么
你可以将概率在所有单个分类器上平均,然后让 Scikit-Learn 给出平均概率最高的类
别作为预测。这被称为软投票法。通常来说,它比硬投票法的表现更优,因为它给予
那些高度自信的投票更高的权重。而所有你需要做的就是用 voting="soft" 代替
voting="hard",并确保所有分类器都可以估算出概率。默认情况下,SVC 类是不行
的,所以你需要将其超参数 probability 设置为 True(这会导致 SVC 使用交叉验证
来估算类别概率,减慢训练速度,并会添加 predict_proba() 方法)。如果修改上面
代码为使用软投票,你会发现投票分类器的准确率达到 91.2% 以上!
7.2 bagging pasting
前面提到,获得不同种类分类器的方法之一是使用不同的训练算法。还有另一种方法是
每个预测器使用的算法相同,但是在不同的训练集随机子集上进行训练。采样时如果将 ...
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.
Start your free trial

You might also like

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

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

George T.Heineman, Gary Pollice, Stanley Selkow
Go语言编程

Go语言编程

威廉·肯尼迪
管理Kubernetes

管理Kubernetes

Brendan Burns, Craig Tracey

Publisher Resources

ISBN: 9787111665977