当前位置:网站首页>[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
边栏推荐
- C language course information management system
- Uniapp component -uni notice bar notice bar
- Force buckle 204 Count prime
- [understanding of opportunity -36]: Guiguzi - flying clamp chapter - prevention against killing and bait
- 【面试题】1369- 什么时候不能使用箭头函数?
- Create your first Kivy program Hello word (tutorial includes source code)
- Wireshark data analysis and forensics a.pacapng
- 电信客户流失预测挑战赛
- C application interface development foundation - form control (1) - form form
- Is there a handling charge for spot gold investment
猜你喜欢

What is tone. Diao's story

Leetcode 2097 - Legal rearrangement of pairs

串口抓包/截断工具的安装及使用详解

wirehark数据分析与取证A.pacapng

Why can't the start method be called repeatedly? But the run method can?

Soft exam information system project manager_ Real topic over the years_ Wrong question set in the second half of 2019_ Morning comprehensive knowledge question - Senior Information System Project Man

Tâche 6: regroupement DBSCAN
![[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](/img/70/54eb9359ac91aa43383b240eb036b7.gif)
[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

C application interface development foundation - form control (3) - file control

Why is it not recommended to use BeanUtils in production?
随机推荐
d. LDC build shared library
Thinkphp+redis realizes simple lottery
tp6快速安装使用MongoDB实现增删改查
2022 cable crane driver examination registration and cable crane driver certificate examination
Steps to obtain SSL certificate private key private key file
Detailed explanation of Q-learning examples of reinforcement learning
MySQL - database query - basic query
【数据挖掘】任务5:K-means/DBSCAN聚类:双层正方形
Top ten regular spot trading platforms 2022
Openresty cache
电信客户流失预测挑战赛
Wireshark data analysis and forensics a.pacapng
Why can't the start method be called repeatedly? But the run method can?
數學知識:臺階-Nim遊戲—博弈論
[interview question] 1369 when can't I use arrow function?
对非ts/js文件模块进行类型扩充
Qtablewidget lazy load remaining memory, no card!
STM32 - vibration sensor control relay on
[keil5 debugging] debug is stuck in reset_ Handler solution
Concise analysis of redis source code 11 - Main IO threads and redis 6.0 multi IO threads