Skip to Content
Python数据科学手册
book

Python数据科学手册

by Jake VanderPlas
January 2018
Intermediate to advanced
470 pages
13h 23m
Chinese
Posts & Telecom Press
Content preview from Python数据科学手册
机器学习
|
391
如果用类似方法为已经做过旋转和平移变换的数据构建一个距离矩阵,将看到同样的
结果:
In[7]: D2 = pairwise_distances(X2)
np.allclose(D, D2)
Out[7]: True
这个距离矩阵给出了一个数据集内部关系的表现形式,这种形式与数据集的旋转和投影无
关。但距离矩阵的可视化效果却显得不够直观。图
5-96
丢失了我们之前在数据中看到的关
于“
HELLO
”的所有视觉特征。
虽然从 (x, y) 坐标计算这个距离矩阵很简单,但是从距离矩阵转换回
x
坐标值和
y
坐标值
却非常困难。这就是多维标度法可以解决的问题:它可以将一个数据集的距离矩阵还原成
一个
D
维坐标来表示数据集。下面来看看多维标度法是如何还原距离矩阵的——
MDS
模
型将非相似性(
dissimilarity
)参数设置为 precomputed 来处理距离矩阵(如图
5-97
所示):
In[8]: from sklearn.manifold import MDS
model = MDS(n_components=2, dissimilarity='precomputed', random_state=1)
out = model.fit_transform(D)
plt.scatter(out[:, 0], out[:, 1], **colorize)
plt.axis('equal');
图 5-97:从成对距离计算 MDS 嵌入
仅仅
依靠描述数据点间关系的
N
×
N
距离矩阵,
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

Luciano Ramalho
Python数据分析基础

Python数据分析基础

Clinton W. Brownley
Python数据处理

Python数据处理

Jacqueline Kazil, Katharine Jarmul

Publisher Resources

ISBN: 9787115475893