当前位置:网站首页>【数据挖掘】任务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
边栏推荐
- [FPGA tutorial case 5] ROM design and Implementation Based on vivado core
- MySQL foundation 05 DML language
- Is there anything in common between spot gold and spot silver
- Pytest learning notes (12) -allure feature · @allure Step () and allure attach
- The latest analysis of tool fitter (technician) in 2022 and the test questions and analysis of tool fitter (technician)
- Related concepts of GDB in embedded system
- The thread reuse problem of PageHelper using ThreadLocal, did you use it correctly?
- 【系统分析师之路】第五章 复盘软件工程(开发模型开发方法)
- C application interface development foundation - form control (2) - MDI form
- 【C语言】指针与数组笔试题详解
猜你喜欢
![[fh-gfsk] fh-gfsk signal analysis and blind demodulation research](/img/8a/8ca80f51a03341c982d52980c54b01.png)
[fh-gfsk] fh-gfsk signal analysis and blind demodulation research

C application interface development foundation - form control (1) - form form

串口抓包/截断工具的安装及使用详解
![[understanding of opportunity -36]: Guiguzi - flying clamp chapter - prevention against killing and bait](/img/c6/9aee30cb935b203c7c62b12c822085.jpg)
[understanding of opportunity -36]: Guiguzi - flying clamp chapter - prevention against killing and bait

Steps to obtain SSL certificate private key private key file

Work experience of a hard pressed programmer

Database SQL language 01 where condition

How is the mask effect achieved in the LPL ban/pick selection stage?

Daily topic: movement of haystack

dotConnect for PostgreSQL数据提供程序
随机推荐
Leetcode skimming questions_ Sum of two numbers II - enter an ordered array
CF1617B Madoka and the Elegant Gift、CF1654C Alice and the Cake、 CF1696C Fishingprince Plays With Arr
MySQL - database query - condition query
Introduction to flask tutorial
[untitled]
openresty 缓存
Main features of transport layer TCP and TCP connection
After reading this article, I will teach you to play with the penetration test target vulnhub - drivetingblues-9
Database SQL language 02 connection query
Kivy教程大全之 创建您的第一个kivy程序 hello word(教程含源码)
Telecom Customer Churn Prediction challenge
Button wizard play strange learning - automatic return to the city route judgment
数学知识:台阶-Nim游戏—博弈论
[fh-gfsk] fh-gfsk signal analysis and blind demodulation research
MySQL --- 数据库查询 - 基本查询
MySQL foundation 05 DML language
[day 29] given an integer, please find its factor number
产业互联网的产业范畴足够大 消费互联网时代仅是一个局限在互联网行业的存在
海量数据冷热分离方案与实践
Wireshark data analysis and forensics a.pacapng