I need minimum euclidean distance algorithm in python to use for a data set which has 72 examples and 5128 features. I searched a lot but wasnt successful. and just found in matlab
You could either check stackoverflow:
https://stackoverflow.com/questions/1871536/minimum-euclidean-distance-between-points-in-two-different-numpy-arrays-not-wit/1871630#1871630
Or the scipy package of python,
https://scikit-learn.org/stable/modules/generated/sklearn.metrics.pairwise.euclidean_distances.html
On the documentation you have some extensive examples on different cases:
https://docs.scipy.org/doc/scipy/reference/spatial.distance.html
I hope some of them help you!
In addition to the answare above I give you a small example using scipy in python:
import scipy.spatial.distance
import numpy
data = numpy.random.random((72,5128))
dists = scipy.spatial.distance.pdist(data)
print("count dists = %d min dist = %d" % (len(dists), min(dists)))
output:
count dists = 2556 min dist = 28
count dists was written to check: 72*71/2 = 2556
for i in range len(x):
distance =+ sqrt(pow(x[i]-y[i]),2)
from scipy.spatial import distance
a = (1, 2, 3)
b = (4, 5, 6)
dst = distance.euclidean(a, b)
Import numpy as np
dist = np.linalg.norm(A-B)
d.append(dist)
Min = min(d)
id = d.index(Min) # the index of the minimum distance
Dear sister, you can get your target from matlab function.
Best wishes
By googling the expression "minimum euclidean distance in python" and exchanging the keywords, you would reach your target.
1. https://stackoverflow.com/questions/1871536/minimum-euclidean-distance-between-points-in-two-different-numpy-arrays-not-wit
2. https://stackoverflow.com/questions/1401712/how-can-the-euclidean-distance-be-calculated-with-numpy
Mansureh Shahraki Moghaddam Hamed Dinari Oriol Sans Planell Tibor Tajti Thank you so much. so usefull!
Salams,you use matlab function after convert it to python.
As pre-requirement to install Cassandra on windows 10, datastax is necessary or python? if python is much more important, is it necessary to have python 2.7? I have' installed python 3.6 (spyder...
06 July 2019 6,762 5 View
I need hierarchical clustering algorithm with single linkage method. whatever I search is the code with using Scikit-Learn. but I dont want that! I want the code with every details of this algorithm.
06 July 2019 453 3 View
Leukemia1 is the dataset of bone marrow and blood samples for leukemia patients at Vanderbilt University . I know that it contains 72 examples and about 5128 features and 3 classes. I searched a...
04 May 2019 7,915 3 View
I have dataset which shows the length of power lines. I need to classify the lines based on the line length. Is there a rule to classify the High voltage (HV) and low voltage (LV) lines based on...
03 March 2021 4,116 4 View
Hi, I am trying to construct a multi-layer fibril structure from a single layer in PyMol by translating the layer along the fibril axis. For now, I am able to use the Translate command in PyMol...
02 March 2021 4,569 4 View
Hello! I have a dataset of n=3000 nested within 8 countries with approximately 200 or 400 responses in each country. I originally planned to perform multilevel modelling with 4 dependent variables...
02 March 2021 6,865 1 View
I would like to research on MR images (0.5T and 3T). Can you please suggest some websites that I can download dataset including both 0.5T and 3T MR images? Thank you.
02 March 2021 7,735 3 View
NFL theorem is valid for algorithms training in fixed training set. However, the general characteristic of algorithms in expanded or open dataset has not been proved yet. Could you show your...
01 March 2021 1,189 3 View
I want to do a parameter study of a aixsymmetric cylinder in Abaqus. I want to create several jobs where I get the stresses for 3 different points in my model. These points are defined. I wrote a...
01 March 2021 10,078 1 View
Dear Researchers I am trying to perform a PIL simulation using STM32F4 Discovery board and comunication serial USB TO TTL. During simulation I receive the following timeout error: An error...
01 March 2021 2,327 1 View
Which is suitable for use with Python? MySQL or SQL Server? What is your suggestion?
01 March 2021 3,422 3 View
I want to differentiate between normal and abnormal movement. For this reason, I am looking forward to this type of dataset.
01 March 2021 9,485 1 View
The following code (see 1st 2 images attached) is used to produce PID controller values that are designed to control the system (G). The code finds the PID controller values (noted as k) by using...
28 February 2021 6,560 14 View