Skip to Main Content
Python 机器学习实践:测试驱动的开发方法
book

Python 机器学习实践:测试驱动的开发方法

by Matthew Kirk
January 2018
Intermediate to advanced content levelIntermediate to advanced
211 pages
8h 31m
Chinese
China Machine Press
Content preview from Python 机器学习实践:测试驱动的开发方法
K
最近邻算法
29
其中
||
x
||
表示之前讨论的欧几里得距离。
通常我们想要的是几何距离。当我们讨论房子时,要用几何距离。但在其他空间中计
算距离、离散距离,以及统计距离等同样重要。
计算距离
想象一下,你想测量从城市的一个部分到另一个部分有多远。一种方法是利用坐标
(经度和纬度)并计算欧几里得距离。假设你位于华盛顿州肯莫尔的圣爱德华州立公
园(
47.7329290
,-
122.2571466
),你想在华盛顿州西雅图国会山的
Vivace Espresso
47.6216650
,-
122.3213002
)会见某人。
使用欧几里得距离,我们将计算:
Cosine similarity
One last geometrical distance is called cosine similarity or cosine distance. The
beauty of this distance is its sheer speed at calculating distances between sparse vec‐
tors. For instance if we had 1,000 attributes collected about houses and 300 of these
were mutually exclusive (meaning that one house had them but the others don’t),
then we would only need to include ...
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

Mastering Python for Bioinformatics

Mastering Python for Bioinformatics

Ken Youens-Clark

Publisher Resources

ISBN: 9787111581666