当前位置:网站首页>[data mining] task 1: distance calculation
[data mining] task 1: distance calculation
2022-07-03 01:38:00 【zstar-_】
subject
Given two tuples (22,1,42,10) and (20,0,36,8) The object of expression
(a) Calculate the Euclidean distance between these two objects ;
(b) Calculate the Manhattan distance between the two objects ;
(c) Use q=3, Calculate the Minkowski distance between the two objects
(d) Calculates the supremum distance between two objects
Create objects
a = (22, 1, 42, 10)
b = (20, 0, 36, 8)
Euclidean distance

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
Manhattan distance


def manhattan(x, y):
return sum(np.abs(x[i] - y[i]) for i in range(len(x)))
manhattan(a, b)
11
Minkowski distance

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
Supremum distance

def Supremum(x, y):
return np.abs(max(x) - max(y))
Supremum(a, b)
6
边栏推荐
- 7-25 read numbers (loop switch)
- The difference between tail -f, tail -f and tail
- Test shift right: Elk practice of online quality monitoring
- Work experience of a hard pressed programmer
- Expérience de recherche d'emploi d'un programmeur difficile
- LeetCode 987. Vertical order transverse of a binary tree - Binary Tree Series Question 7
- What are the trading forms of spot gold and what are the profitable advantages?
- Using tensorboard to visualize the model, data and training process
- [fh-gfsk] fh-gfsk signal analysis and blind demodulation research
- [system analyst's road] Chapter V double disk software engineering (development model development method)
猜你喜欢

View of MySQL

Everything文件搜索工具

Pytest learning notes (12) -allure feature · @allure Step () and allure attach

STM32 - vibration sensor control relay on

Why can't the start method be called repeatedly? But the run method can?

并发编程的三大核心问题 -《深入理解高并发编程》

看完这篇 教你玩转渗透测试靶机Vulnhub——DriftingBlues-9

Work experience of a hard pressed programmer

Installation and use of serial port packet capturing / cutting tool

LeetCode 987. Vertical order transverse of a binary tree - Binary Tree Series Question 7
随机推荐
2022 Jiangxi Provincial Safety Officer B certificate reexamination examination and Jiangxi Provincial Safety Officer B certificate simulation examination question bank
The meaning of wildcard, patsubst and notdir in makefile
word插入公式/endnote
leetcode刷题_两数之和 II - 输入有序数组
Expérience de recherche d'emploi d'un programmeur difficile
What is tone. Diao's story
【数据挖掘】任务5:K-means/DBSCAN聚类:双层正方形
LDC Build Shared Library
Thinkphp+redis realizes simple lottery
Vim 9.0正式发布!新版脚本执行速度最高提升100倍
Kivy tutorial how to create drop-down lists in Kivy
C#应用程序界面开发基础——窗体控制(2)——MDI窗体
【数据挖掘】任务6:DBSCAN聚类
[androd] module dependency replacement of gradle's usage skills
2022-02-15 reading the meta module inspiration of the influxdb cluster
A simple tool for analyzing fgui dependencies
C语言课程信息管理系统
看疫情之下服装企业如何顺势而为
tp6快速安装使用MongoDB实现增删改查
Druid database connection pool