当前位置:网站首页>【数据挖掘】任务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
边栏推荐
- Is there anything in common between spot gold and spot silver
- SwiftUI 组件大全之使用 SceneKit 和 SwiftUI 构建交互式 3D 饼图(教程含源码)
- Using tensorboard to visualize the model, data and training process
- [FPGA tutorial case 6] design and implementation of dual port RAM based on vivado core
- The latest analysis of tool fitter (technician) in 2022 and the test questions and analysis of tool fitter (technician)
- Basis of information entropy
- MySQL - database query - condition query
- Detailed explanation of Q-learning examples of reinforcement learning
- [understanding of opportunity -36]: Guiguzi - flying clamp chapter - prevention against killing and bait
- 2022 cable crane driver examination registration and cable crane driver certificate examination
猜你喜欢
简易分析fgui依赖关系工具
What is tone. Diao's story
C application interface development foundation - form control (2) - MDI form
Androd Gradle 对其使用模块依赖的替换
【QT】自定义控件的封装
MySQL - database query - condition query
[androd] module dependency replacement of gradle's usage skills
Using tensorboard to visualize the model, data and training process
Meituan dynamic thread pool practice ideas, open source
CF1617B Madoka and the Elegant Gift、CF1654C Alice and the Cake、 CF1696C Fishingprince Plays With Arr
随机推荐
Druid database connection pool
tp6快速安装使用MongoDB实现增删改查
MySQL basics 03 introduction to MySQL types
2022 cable crane driver examination registration and cable crane driver certificate examination
MySQL foundation 05 DML language
After reading this article, I will teach you to play with the penetration test target vulnhub - drivetingblues-9
[Cao gongzatan] after working in goose factory for a year in 2021, some of my insights
CF1617B Madoka and the Elegant Gift、CF1654C Alice and the Cake、 CF1696C Fishingprince Plays With Arr
Wireshark data analysis and forensics a.pacapng
Type expansion of non ts/js file modules
数学知识:Nim游戏—博弈论
Look at how clothing enterprises take advantage of the epidemic
Using tensorboard to visualize the model, data and training process
[androd] module dependency replacement of gradle's usage skills
wirehark数据分析与取证A.pacapng
【系统分析师之路】第五章 复盘软件工程(开发模型开发方法)
2022 Jiangxi Provincial Safety Officer B certificate reexamination examination and Jiangxi Provincial Safety Officer B certificate simulation examination question bank
Steps to obtain SSL certificate private key private key file
MySQL foundation 06 DDL
JDBC courses