当前位置:网站首页>【数据挖掘】任务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
边栏推荐
- LDC Build Shared Library
- [system analyst's road] Chapter V double disk software engineering (development model development method)
- C application interface development foundation - form control (1) - form form
- How is the mask effect achieved in the LPL ban/pick selection stage?
- 数学知识:能被整除的数—容斥原理
- 什么是调。调的故事
- JUC thread scheduling
- What are the trading forms of spot gold and what are the profitable advantages?
- Look at how clothing enterprises take advantage of the epidemic
- The meaning of wildcard, patsubst and notdir in makefile
猜你喜欢

海量数据冷热分离方案与实践

Summary of interval knowledge

Installation and use of serial port packet capturing / cutting tool

强化学习 Q-learning 实例详解
![[untitled]](/img/fd/f6b90536f10325a6fdeb68dc49c72d.png)
[untitled]

Learn the five skills you need to master in cloud computing application development

Basic remote connection tool xshell

Daily topic: movement of haystack

Database SQL language 02 connection query

C#应用程序界面开发基础——窗体控制(3)——文件类控件
随机推荐
MySQL foundation 07-dcl
Tp6 fast installation uses mongodb to add, delete, modify and check
Pytest learning notes (12) -allure feature · @allure Step () and allure attach
High-Resolution Network (篇一):原理刨析
Makefile中wildcard、patsubst、notdir的含义
Concise analysis of redis source code 11 - Main IO threads and redis 6.0 multi IO threads
C#应用程序界面开发基础——窗体控制(4)——选择类控件
JUC thread scheduling
[fh-gfsk] fh-gfsk signal analysis and blind demodulation research
wirehark数据分析与取证A.pacapng
Why is it not recommended to use BeanUtils in production?
C语言课程信息管理系统
软考信息系统项目管理师_历年真题_2019下半年错题集_上午综合知识题---软考高级之信息系统项目管理师053
一比特苦逼程序員的找工作經曆
GDB 在嵌入式中的相关概念
The latest analysis of tool fitter (technician) in 2022 and the test questions and analysis of tool fitter (technician)
[principles of multithreading and high concurrency: 2. Solutions to cache consistency]
SwiftUI 组件大全之使用 SceneKit 和 SwiftUI 构建交互式 3D 饼图(教程含源码)
C application interface development foundation - form control (2) - MDI form
Create your first Kivy program Hello word (tutorial includes source code)