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 版)
降维
|
203
小于
n
时,它比完全的 SVD 快得多:
rnd_pca = PCA(n_components=154, svd_solver="randomized")
X_reduced = rnd_pca.fit_transform(X_train)
默认情况下,svd_solver 实际上设置为 "auto" :如果
m
或
n
大于 500 并且
d
小于
m
或
n
的 80%,则 Scikit-Learn 自动使用随机 PCA 算法,否则它将使用完全的 SVD 方
法。如果要强制 Scikit-Learn 使用完全的SVD,可以将 svd_solver 超参数设置为
"full"。
8.3.9 增量 PCA
前面的 PCA 实现的一个问题是,它们要求整个训练集都放入内存才能运行算法。幸运
的是已经开发了增量
PCA
(IPCA)算法,它们可以使你把训练集划分为多个小批量,并
一次将一个小批量送入 IPCA 算法。这对于大型训练集和在线(即在新实例到来时动态
运行)应用 PCA 很有用。
以下代码将 MNIST 数据集拆分为 100 个小批量(使用 NumPy 的 array_split() 函
数),并将其馈送到 Scikit-Learn 的 IncrementalPCA 类
注 5
,来把 MNIST 数据集的维
度降低到 154(就像之前做的那样)。请注意,你必须在每个小批量中调用 partial_
fit() 方法,而不是在整个训练集中调用 fit() 方法:
1
from sklearn.decomposition ...
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