当前位置:网站首页>[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
边栏推荐
- 网络安全-openvas
- leetcode刷题_两数之和 II - 输入有序数组
- How is the mask effect achieved in the LPL ban/pick selection stage?
- 看完这篇 教你玩转渗透测试靶机Vulnhub——DriftingBlues-9
- C#应用程序界面开发基础——窗体控制(2)——MDI窗体
- Give you an array numbers that may have duplicate element values. It was originally an array arranged in ascending order, and it was rotated once according to the above situation. Please return the sm
- Related concepts of GDB in embedded system
- Type expansion of non ts/js file modules
- Arduino dy-sv17f automatic voice broadcast
- Leetcode skimming questions_ Sum of two numbers II - enter an ordered array
猜你喜欢
![[data mining] task 5: k-means/dbscan clustering: double square](/img/e7/678197e703d1a28b765a0e3afd5580.png)
[data mining] task 5: k-means/dbscan clustering: double square

给你一个可能存在 重复 元素值的数组 numbers ,它原来是一个升序排列的数组,并按上述情形进行了一次旋转。请返回旋转数组的最小元素。【剑指Offer】

力扣 204. 计数质数

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

Leetcode 2097 - Legal rearrangement of pairs

Using tensorboard to visualize the model, data and training process

Top ten regular spot trading platforms 2022

Why is it not recommended to use BeanUtils in production?

Androd gradle's substitution of its use module dependency

What is tone. Diao's story
随机推荐
C application interface development foundation - form control (1) - form form
Smart management of Green Cities: Digital twin underground integrated pipe gallery platform
2022 cable crane driver examination registration and cable crane driver certificate examination
Tâche 6: regroupement DBSCAN
Using tensorboard to visualize the model, data and training process
The latest analysis of tool fitter (technician) in 2022 and the test questions and analysis of tool fitter (technician)
Concise analysis of redis source code 11 - Main IO threads and redis 6.0 multi IO threads
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
C application interface development foundation - form control (4) - selection control
对非ts/js文件模块进行类型扩充
MySQL - database query - condition query
海量数据冷热分离方案与实践
Three core issues of concurrent programming - "deep understanding of high concurrent programming"
Androd gradle's substitution of its use module dependency
[untitled]
ThinkPHP+Redis实现简单抽奖
一比特苦逼程序員的找工作經曆
[FPGA tutorial case 6] design and implementation of dual port RAM based on vivado core
【面试题】1369- 什么时候不能使用箭头函数?
Leetcode 6103 - minimum fraction to delete an edge from the tree