Skip to Content
数据科学中的实用统计学(第2版)
book

数据科学中的实用统计学(第2版)

by Peter Bruce, Andrew Bruce, Peter Gedeck
October 2021
Intermediate to advanced
289 pages
8h 31m
Chinese
Posts & Telecom Press
Content preview from 数据科学中的实用统计学(第2版)
无监督学习
265
7.5.4
 混合数据聚类中的问题
K-
均值和
PCA
最适用于连续型变量。对于较小的数据集,使用基于
Gower
距离的层次聚
类效果更好。理论上,
K-
均值可以用于二元数据和分类型数据
。通常需要使用“独热编
码”(参见
6.1.3
节)将分类型数据转换为数值型数据
。在实践中,很难在二元数据上使用
K-
均值和
PCA
方法。
如果使用标准的
z
分数
,二元变量就会主导簇的生成过程,这是因为
0/1
变量只有两个取
值,如果将所有取值为
0
或取值为
1
的记录放在一个簇里
K-
均值就可以得到一个非常小
的簇内平方和。举例来说,我们在包含了因子变量
home
pub_rec_zero
的贷款违约数据
上使用
K-
均值。以下是
R
代码:
df <- model.matrix(~ -1 + dti + payment_inc_ratio + home_ + pub_rec_zero,
data=defaults)
df0 <- scale(df)
km0 <- kmeans(df0, centers=4, nstart=10)
centers0 <- scale(km0$centers, center=FALSE,
scale=1/attr(df0, 'scaled:scale'))
round(scale(centers0, center=-attr(df0, 'scaled:center'), scale=FALSE), 2)
dti payment_inc_ratio home_MORTGAGE home_OWN home_RENT ...
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

Python机器学习案例精解

Python机器学习案例精解

Posts & Telecom Press, Yuxi (Hayden) Liu

Publisher Resources

ISBN: 9787115569028