当前位置:网站首页>【数据挖掘】任务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
边栏推荐
- JUC thread scheduling
- High-Resolution Network (篇一):原理刨析
- After reading this article, I will teach you to play with the penetration test target vulnhub - drivetingblues-9
- 什么是调。调的故事
- Thinkphp+redis realizes simple lottery
- Scheme and practice of cold and hot separation of massive data
- [Arduino experiment 17 L298N motor drive module]
- MySQL - database query - basic query
- C application interface development foundation - form control (4) - selection control
- Test shift right: Elk practice of online quality monitoring
猜你喜欢
MySQL - database query - basic query
看完这篇 教你玩转渗透测试靶机Vulnhub——DriftingBlues-9
Niu Ke swipes questions and clocks in
Learn the five skills you need to master in cloud computing application development
【数据挖掘】任务4:20Newsgroups聚类
[技术发展-23]:DSP在未来融合网络中的应用
C#应用程序界面开发基础——窗体控制(2)——MDI窗体
力扣 204. 计数质数
【數據挖掘】任務6:DBSCAN聚類
Qtablewidget lazy load remaining memory, no card!
随机推荐
[自我管理]时间、精力与习惯管理
VIM 9.0 is officially released! The execution speed of the new script can be increased by up to 100 times
C application interface development foundation - form control (4) - selection control
High-Resolution Network (篇一):原理刨析
Machine learning terminology
LeetCode 987. Vertical order transverse of a binary tree - Binary Tree Series Question 7
The thread reuse problem of PageHelper using ThreadLocal, did you use it correctly?
Kivy教程大全之 创建您的第一个kivy程序 hello word(教程含源码)
MySQL basics 03 introduction to MySQL types
The industrial scope of industrial Internet is large enough. The era of consumer Internet is only a limited existence in the Internet industry
MySQL - database query - condition query
Kivy tutorial - example of using Matplotlib in Kivy app
MySQL --- 数据库查询 - 条件查询
Makefile中wildcard、patsubst、notdir的含义
[day 29] given an integer, please find its factor number
[机缘参悟-36]:鬼谷子-飞箝篇 - 面对捧杀与诱饵的防范之道
Mathematical Knowledge: Steps - Nim Games - Game Theory
The latest analysis of tool fitter (technician) in 2022 and the test questions and analysis of tool fitter (technician)
Qtablewidget lazy load remaining memory, no card!
Concise analysis of redis source code 11 - Main IO threads and redis 6.0 multi IO threads