All Questions
Tagged with euclidean-distance python-3.x
33
questions
15
votes
3
answers
2k
views
Efficient calculation of euclidean distance
I have a MxN array, where M is the number of observations and N is the dimensionality of each vector. From this array of vectors, I need to calculate the mean and minimum euclidean distance between ...
14
votes
6
answers
23k
views
Efficient and precise calculation of the euclidean distance
Following some online research (1, 2, numpy, scipy, scikit, math), I have found several ways for calculating the Euclidean Distance in Python:
# 1
numpy.linalg.norm(a-b)
# 2
distance.euclidean(...
12
votes
3
answers
32k
views
Distance between nodes and the centroid in a kmeans cluster?
Any option to extract the distance between the nodes and the centroid in a kmeans cluster.
I have done Kmeans clustering over an text embedding data set and I want to know which are the nodes that ...
3
votes
2
answers
3k
views
Creating an equilateral triangle for given two points in the plane - Python
I have two points X = (x1,y1) and Y=(x2,y2) in the Cartesian plane. I need to find the third point Z = (x,y) such that these three points make an equilateral triangle.
I'm calculating the Euclidean ...
3
votes
1
answer
7k
views
Distance between nodes using python networkx
I am new to NetworkX, and I need to find the distance between two nodes. I have given it a go, but most of the searches lead to the DFS, Dijkstra, etc. approaches, which is not my point. I only want ...
3
votes
1
answer
1k
views
What is the most efficient way to compute the square euclidean distance between N samples and clusters centroids?
I am looking for an efficient way (no for loops) to compute the euclidean distance between a set of samples and a set of clusters centroids.
Example:
import numpy as np
X = np.array([[1,2,3],[1, 1, ...
3
votes
0
answers
113
views
How to calculate euclidean distance of a column with all the sublist of another column with respect to grouping in pandas dataframe?
I have following dataframe,
mac1 mac2 uuid val refVal
0 ...
2
votes
2
answers
6k
views
Apply function to each element in 3 lists of tuples to get 1 resultant list python3
I am trying to calculate a resultant acceleration from x, y, z accelerations. I have written a function that does this when manually inputting the x,y,z coordinates.
def Euclidean_norm(x,y,z):
...
2
votes
1
answer
1k
views
How to calculate the euclidean distance between neighbors in networkx using x,y coordinates automatically and find the minimum spanning tree
So far I calculate the euclidean distance between the neighbors manually. But I need help on our to calculate the distance automatically in the code. My code so far is:
import networkx as nx
...
2
votes
1
answer
243
views
segmentation of elements of a list into sub-groups according to the distance between it
How to subdivide the elements of the list (list of distance ) into groups according to the distance (euclidean-distance where the indices is supposed as angle) between the elements using python like ...
2
votes
1
answer
199
views
Remove point from list if within certain threshold of any other point
I have code that filters points from a list where the distance between them is below 3:
import numpy
lst_x = [0,1,2,3,4,5,6,7,8,9,10]
lst_y = [9,1,3,2,7,6,2,7,2,3,8]
lst = numpy.column_stack((lst_x,...
2
votes
1
answer
3k
views
Calculate Euclidean Distance for Latitude and Longitude - Pandas DataFrame Python [duplicate]
I have a pandas df of origin and destination latitude and longitude.
df = pd.DataFrame({'orig_lat': [32.8111, 34.3424], 'orig_long': [-122.2221,-132.2133],
'dest_lat': [33.2231, 35.3394], '...
1
vote
2
answers
459
views
How to calculate the distance in Python
let said I have two arrays of points, and I want to know what is the distance between each point.
For example:
array_1 = [p1,p2,p3,p4]
array_2 = [p5,p6]
p1 to p6 is point, something like [1,1,1] (...
1
vote
3
answers
1k
views
How to reorder coordinate values using the euclidian distance in Python?
I want to reorder the coordinate value based on the euclidean distance .
For example I have coordinates:
1 2
2 1
1 3
1 9
6 9
3 5
6 8
4 5
7 9
I have got euclidean distance of first coordinate with ...
1
vote
2
answers
2k
views
Finding pairs of latitude and longitude within a certain radius in Python
Given a dataframe df as follows:
id location lon lat
0 1 Onyx Spire 116.35425 39.87760
1 2 Unison Lookout 116.44333 39.93237
2 3 ...
1
vote
2
answers
1k
views
How to implement in Python a function to compute the Euclidean distance between two arbitrary points on a torus
Given a 10x10 grid (2d-array) filled randomly with numbers, either 0, 1 or 2. How can I find the Euclidean distance (the l2-norm of the distance vector) between two given points considering periodic ...
1
vote
4
answers
2k
views
Find the index of points closest to each other in a list
I have been having trouble implementing the function in order to find the closest point, I've tried multiple ways of doing it but I just can't seem to figure it out. Any ideas on how I should go about ...
1
vote
1
answer
551
views
Find euclidean distance between rows of two huge CSR matrices
I have two sparse martrices, A and B. A is 120000*5000 and B is 30000*5000. I need to find the euclidean distances between each row in B with all rows of A and then find the 5 rows in A with the ...
0
votes
1
answer
2k
views
Comparing X Y coordinates of the same list
I have a list of X Y tuple coordinates. I am trying to eliminate the coordinates that are very close to each other using the euclidean distance. However, the code so far does not perform as expected, ...
0
votes
2
answers
1k
views
How to apply the distance formula to a list of [x,y] coordinates in python
In order to solve the Traveling Salesman Problem (TSP) using a genetic algorithm, I am randomly generating a list of Z points on an N by N grid:
field = [random.sample(range(N), 2) for x in range(Z)]
...
0
votes
2
answers
464
views
Determine closest location using euclidian distance in Python
So I'm struggling to find the closest Euclidean distance of two coordinates from data in a dictionary.
First, I have figured out how to compute the distance between two Cartesian coordinates (x,y) ...
0
votes
1
answer
144
views
How to reduce execution time while evaluating each item in a list in python
I have to build a distance matrix for locations
addresses = [(10.0, 20.0), (21.2318, 72.903), (26.4499, 80.3319), (20.0, 20.0), (19.114, 72.8927), (20.4189, 77.0153), (28.5377, 77.1217), (28.6201, 77....
0
votes
1
answer
209
views
find coordinates from a point and giving distancein plot
Let's say I'm moving from the top of the peak with a giving distance of 1 nm before the peak (at left). How can I get the index or the coordinate of the arrival point?
data looks like this:
timeInS= ...
0
votes
1
answer
3k
views
How to do face recognition using euclidean distance in python
I have a project where I need to include face recognition in it. I am referring to this article. This article is using open-face to get the face embeddings and its saving all the embeddings in a ...
0
votes
0
answers
89
views
Else statement executing even though the if statement is true
for school i am making an assignment, implementing astar search with the use of dictionaries. I have been trying a few things, but now i am stuck. in my first iteration the if statement if f_next < ...
0
votes
0
answers
64
views
Trying to find with euclidean distance the closest ones
import imagehash
from PIL import Image
import glob
import numpy as np
import csv
from scipy.spatial import distance
image_list = []
list_rows = []
for filename in glob.glob('/home/folder1/*.jpg'):
...
0
votes
2
answers
55
views
Calculate Euclidean distance of ATMs
enter image description here
I need to group the atms by banks (clean_name) and calculate the distance of each atms within a particular bank and find the max euclidean distance.
not sure how to apply ...
0
votes
1
answer
341
views
Getting IndexError: list index out of range when calculating Euclidean distance
I am trying to apply the code provided at https://towardsdatascience.com/3-basic-distance-measurement-in-text-mining-5852becff1d7 . When I use this with my own data I seem to access a part of list ...
0
votes
1
answer
291
views
How to apply different weights to different dimensions for distance metric in python?
I'm trying to modify a minkowski distance that can either be euclidean or manhattan in which each dimension can be weighted differently. I've seen posts that give an answer using scipy that appear to ...
0
votes
1
answer
133
views
Finding Euclidean distance from a m*n dimensional matrix to a point
I am working on a clustering problem. There's a situation where I have 3 cluster centers as below, and I want to calculate euclidean distance from these 3 cluster centers from another m*n dimensional ...
0
votes
2
answers
718
views
How to measure the length of a 2-dimensional path in separate steps
I am a newbie in python. I am stuck by finding the length of a path in 2d. I have no idea what I'm doing wrong. Please help!
import math
vector1 = v1
vector2 = v2
def length (v):
""" Length of a ...
-1
votes
2
answers
1k
views
Creating a distance matrix from a matrix/list
I have created a list from the input and from the list I have created a matrix also.
list-
('A', 'B', 3)
('A', 'D', 4)
('B', 'D', 4)
('B', 'H', 5)
('C', 'L', 2)
('D', 'F', 1)
('F', 'H', 3)
('G', 'H', ...
-1
votes
1
answer
448
views
TypeError: family() missing 1 required positional argument: 'rebw'
Getting is error how can I fix it? Please help
here is the complete Error which is showing me in Terminal:
Traceback (most recent call last):
File "Family-tracking-system.py", line 843, in search
...