当前位置:网站首页>【数据挖掘】任务1:距离计算
【数据挖掘】任务1:距离计算
2022-07-03 01:09:00 【zstar-_】
题目
给定两个被元组(22,1,42,10)和(20,0,36,8)表示的对象
(a)计算这两个对象之间的欧几里得距离;
(b)计算这两个对象之间的曼哈顿距离;
(c)使用q=3,计算这两个对象之间的闵可夫斯基距离
(d)计算着两个对象之间的上确界距离
创建对象
a = (22, 1, 42, 10)
b = (20, 0, 36, 8)
欧氏距离

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
曼哈顿距离


def manhattan(x, y):
return sum(np.abs(x[i] - y[i]) for i in range(len(x)))
manhattan(a, b)
11
闵可夫斯基距离

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
上确界距离

def Supremum(x, y):
return np.abs(max(x) - max(y))
Supremum(a, b)
6
边栏推荐
- Leetcode 6103 - minimum fraction to delete an edge from the tree
- After reading this article, I will teach you to play with the penetration test target vulnhub - drivetingblues-9
- [interview question] 1369 when can't I use arrow function?
- [principles of multithreading and high concurrency: 2. Solutions to cache consistency]
- Leetcode 2097 - Legal rearrangement of pairs
- Arduino dy-sv17f automatic voice broadcast
- 传输层 TCP主要特点和TCP连接
- 数学知识:能被整除的数—容斥原理
- 不登陆或者登录解决oracle数据库账号被锁定。
- Create your first Kivy program Hello word (tutorial includes source code)
猜你喜欢

力扣 204. 计数质数
![[机缘参悟-36]:鬼谷子-飞箝篇 - 面对捧杀与诱饵的防范之道](/img/c6/9aee30cb935b203c7c62b12c822085.jpg)
[机缘参悟-36]:鬼谷子-飞箝篇 - 面对捧杀与诱饵的防范之道

MySQL - database query - basic query

Daily topic: movement of haystack
![[fh-gfsk] fh-gfsk signal analysis and blind demodulation research](/img/8a/8ca80f51a03341c982d52980c54b01.png)
[fh-gfsk] fh-gfsk signal analysis and blind demodulation research
![[technology development-23]: application of DSP in future converged networks](/img/2e/f39543a18a8f58b1d341ce72cc4427.png)
[technology development-23]: application of DSP in future converged networks

leetcode 2097 — 合法重新排列数对

Steps to obtain SSL certificate private key private key file

Dotconnect for PostgreSQL data provider

wirehark数据分析与取证A.pacapng
随机推荐
JDBC courses
The difference between tail -f, tail -f and tail
给你一个可能存在 重复 元素值的数组 numbers ,它原来是一个升序排列的数组,并按上述情形进行了一次旋转。请返回旋转数组的最小元素。【剑指Offer】
leetcode 2097 — 合法重新排列数对
Androd gradle's substitution of its use module dependency
简易分析fgui依赖关系工具
C application interface development foundation - form control (4) - selection control
并发编程的三大核心问题 -《深入理解高并发编程》
Androd Gradle 对其使用模块依赖的替换
[Cao gongzatan] after working in goose factory for a year in 2021, some of my insights
Pytest learning notes (12) -allure feature · @allure Step () and allure attach
MySQL --- 数据库查询 - 条件查询
【我的OpenGL学习进阶之旅】关于欧拉角、旋转顺序、旋转矩阵、四元数等知识的整理
Learn the five skills you need to master in cloud computing application development
SSL flood attack of DDoS attack
What are the trading forms of spot gold and what are the profitable advantages?
The thread reuse problem of PageHelper using ThreadLocal, did you use it correctly?
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
High-Resolution Network (篇一):原理刨析
C#应用程序界面开发基础——窗体控制(2)——MDI窗体