Skip to Content
面向数据科学家的实用统计学
book

面向数据科学家的实用统计学

by Peter Bruce, Andrew Bruce
October 2018
Beginner to intermediate
238 pages
6h 32m
Chinese
Posts & Telecom Press
Content preview from 面向数据科学家的实用统计学
216
|
第
7
章
方法,具体使用的处理方法取决于应用。
图 7-12:添加 GOOGL 和 AMZN 股票后,标准普尔 500 指数中排名靠前的几家公司股票的主成分
分析的陡坡图
7.5.3
 分类数据和高氏距离
分类数据必须要转换为数值型数据。转换可以通过排序(对于有序因子)实现,也可以通
过编码为一组二元变量(虚拟变量)实现。如果数据中有连续变量和二元变量,那么一般
需要缩放变量,使各个变量间具有相似的范围(参见
7.5.1
节)。一种常用方法是使用
高氏
距离
。
高氏距离的基本思想是,根据数据类型,对每个变量应用不同的距离度量。
•
对于数值型变量和有序因子,高氏距离计算为两条记录间差异的绝对值(即
曼哈顿距离
)。
•
对于分类变量,如果两个记录属于不同的类,那么距离为
1
;如果它们属于同一个分类,
那么距离为
0
。
高氏距离的计算步骤如下。
(1)
对每条记录,计算所有变量对
i
和
j
间的距离
d
i
,
j
。
(2)
将每个距离
d
i
,
j
缩放到区间
[0, 1]
中。
(3)
使用简单均值或加权均值,将所有变量对间的缩放距离相加,创建一个距离矩阵。
为了更好地解释高氏距离,我们以贷款数据为例,从数据中取几行。
无监督学习
|
217
> x = defaults[1:5, c('dti', 'payment_inc_ratio', 'home', ...
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的智能文本分析

Benjamin Bengfort, Rebecca Bilbro, Tony Ojeda
Python数据处理

Python数据处理

Jacqueline Kazil, Katharine Jarmul
精通機器學習

精通機器學習

Aurélien Géron
C++语言导学(原书第2版)

C++语言导学(原书第2版)

本贾尼 斯特劳斯特鲁普

Publisher Resources

ISBN: 9787115493668