当前位置:网站首页>[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#应用程序界面开发基础——窗体控制(4)——选择类控件
- [androd] module dependency replacement of gradle's usage skills
- [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
- Meituan dynamic thread pool practice ideas, open source
- [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
- Introduction to flask tutorial
- Concise analysis of redis source code 11 - Main IO threads and redis 6.0 multi IO threads
- C application interface development foundation - form control (4) - selection control
- C application interface development foundation - form control (3) - file control
猜你喜欢
Androd gradle's substitution of its use module dependency
Leetcode 2097 - Legal rearrangement of pairs
Arduino dy-sv17f automatic voice broadcast
[principles of multithreading and high concurrency: 2. Solutions to cache consistency]
Virtual list
Everything文件搜索工具
Androd Gradle 对其使用模块依赖的替换
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
STM32 - Application of external interrupt induction lamp
QTableWidget懒加载剩内存,不卡!
随机推荐
A simple tool for analyzing fgui dependencies
C language course information management system
The difference between tail -f, tail -f and tail
The thread reuse problem of PageHelper using ThreadLocal, did you use it correctly?
Mathematical knowledge: step Nim game game game theory
LeetCode 987. Vertical order transverse of a binary tree - Binary Tree Series Question 7
C application interface development foundation - form control (4) - selection control
High resolution network (Part 1): Principle Analysis
VIM 9.0 is officially released! The execution speed of the new script can be increased by up to 100 times
Pytest learning notes (12) -allure feature · @allure Step () and allure attach
[principles of multithreading and high concurrency: 2. Solutions to cache consistency]
Arduino DY-SV17F自动语音播报
CF1617B Madoka and the Elegant Gift、CF1654C Alice and the Cake、 CF1696C Fishingprince Plays With Arr
C application interface development foundation - form control (2) - MDI form
Look at how clothing enterprises take advantage of the epidemic
Wireshark data analysis and forensics a.pacapng
网络安全-扫描
【数据挖掘】任务2:医学数据库MIMIC-III数据处理
一位苦逼程序员的找工作经历
[untitled]