当前位置:网站首页>[data mining] task 1: distance calculation
[data mining] task 1: distance calculation
2022-07-03 01:38:00 【zstar-_】
subject
Given two tuples (22,1,42,10) and (20,0,36,8) The object of expression
(a) Calculate the Euclidean distance between these two objects ;
(b) Calculate the Manhattan distance between the two objects ;
(c) Use q=3, Calculate the Minkowski distance between the two objects
(d) Calculates the supremum distance between two objects
Create objects
a = (22, 1, 42, 10)
b = (20, 0, 36, 8)
Euclidean distance
import numpy as np
def euclidean(x, y):
return np.sqrt(sum((x[i] - y[i]) ** 2 for i in range(len(x))))
euclidean(a, b)
6.708203932499369
Manhattan distance
def manhattan(x, y):
return sum(np.abs(x[i] - y[i]) for i in range(len(x)))
manhattan(a, b)
11
Minkowski distance
def minkowski(x, y, p):
return sum(np.abs(x[i] - y[i]) ** p for i in range(len(x))) ** (1 / p)
minkowski(a, b, 3)
6.153449493663682
Supremum distance
def Supremum(x, y):
return np.abs(max(x) - max(y))
Supremum(a, b)
6
边栏推荐
- CF1617B Madoka and the Elegant Gift、CF1654C Alice and the Cake、 CF1696C Fishingprince Plays With Arr
- 软考信息系统项目管理师_历年真题_2019下半年错题集_上午综合知识题---软考高级之信息系统项目管理师053
- [shutter] animation animation (animatedwidget animation use process | create animation controller | create animation | create animatedwidget animation component | animation operation)
- 看疫情之下服装企业如何顺势而为
- JUC thread scheduling
- STM32 - GPIO input / output mode
- 【数据挖掘】任务6:DBSCAN聚类
- Swiftui component Encyclopedia: using scenekit and swiftui to build interactive 3D pie charts (tutorial with source code)
- C application interface development foundation - form control (2) - MDI form
- Type expansion of non ts/js file modules
猜你喜欢
[shutter] animation animation (basic process of shutter animation | create animation controller | create animation | set value listener | set state listener | use animation values in layout | animatio
[shutter] animation animation (animatedbuilder animation use process | create animation controller | create animation | create components for animation | associate animation with components | animatio
How is the mask effect achieved in the LPL ban/pick selection stage?
[North Asia data recovery] data recovery case of raid crash caused by hard disk disconnection during data synchronization of hot spare disk of RAID5 disk array
[technology development-23]: application of DSP in future converged networks
串口抓包/截断工具的安装及使用详解
C#应用程序界面开发基础——窗体控制(2)——MDI窗体
Dotconnect for PostgreSQL data provider
Three core issues of concurrent programming - "deep understanding of high concurrent programming"
STM32 - vibration sensor control relay on
随机推荐
A simple tool for analyzing fgui dependencies
Wordinsert formula /endnote
软考信息系统项目管理师_历年真题_2019下半年错题集_上午综合知识题---软考高级之信息系统项目管理师053
The latest analysis of tool fitter (technician) in 2022 and the test questions and analysis of tool fitter (technician)
Androd Gradle 对其使用模块依赖的替换
2022 cable crane driver examination registration and cable crane driver certificate examination
Button wizard play strange learning - automatic return to the city route judgment
数学知识:能被整除的数—容斥原理
d. LDC build shared library
Leetcode 6103 - minimum fraction to delete an edge from the tree
7-25 read numbers (loop switch)
The industrial scope of industrial Internet is large enough. The era of consumer Internet is only a limited existence in the Internet industry
Summary of interval knowledge
Is there a handling charge for spot gold investment
Using tensorboard to visualize the model, data and training process
Tâche 6: regroupement DBSCAN
【數據挖掘】任務6:DBSCAN聚類
[FPGA tutorial case 6] design and implementation of dual port RAM based on vivado core
Common English Vocabulary
C#应用程序界面开发基础——窗体控制(2)——MDI窗体