Distance Calculcations
- 1 Finding Bray-Curtis distance using SciPy Bray-Curtis distance finds the dissimilarity between the species found at two regions and is often used in ecology studies. The Python example finds the dissimilarity using the scipy function braycurtis(). 11 Jul 2025
- 2 Computing Canberra distance using Python Canberra distance is a dissimilarity measure that accentuates the distance between two sequences when corresponding elements are closer to zero. The Python example computes the Canberra distance between two sequences. 21 Jul 2025
- 3 Computing Chebyshev distance using Python Given two n-dimensional points, the Chebyshev distance returns the maximum of axis-wise differences. The Python example finds the Chebyshev distances between two 2-dimensional points and two 3-dimensional points. 22 Jul 2025
- 4 Computing Dice dissimilarity using Python The Dice dissimilarity between two vectors is given by the formula b+c/2a+b+c whose entries are from the contingency table. The Dice dissimilarity gives more weightage to the case of both the vectors having True for corresponding elements. 23 Jul 2025
- 5 Finding the Euclidean distance between points using SciPy The Euclidean distance between two points in n-dimensional space is computed as sqrt(sum(xi-yi)2). The Python example uses the scipy function to compute the Euclidean distance between two points a two-dimensional plane. 16 Jul 2025
- 6 Hamming distance using SciPy The Hamming distance describes how many elements differ between two strings or one-dimensional arrays of same length. The SciPy function hamming() of the distance module returns this distance as a percentage. 15 Jul 2025
- 7 Computing Jaccard dissimilarity using Python The Jaccard dissimilarity between two vectors of boolean values is given by J(i, j) = b + c/a + b + c. The variables a, b, c are from the contingency table. The Python example finds the Jaccard dissimilarity between two species. 23 Jul 2025
- 8 Finding mahalanobis distance using Python The Mahalanobis distance computes the distance between a multivariate distribution and a multivariate data. The Mahalanobis distance is to the multivariate distribution what the z-score is for the univariate distribution. 18 Jul 2025
- 9 Computing Manhattan distance using Python The function cityblock() computes the Manhattan distance between two points in the real co-ordinate space. The Pythone example computes the distance using the same data points 16 Jul 2025
- 10 Computing the Minkowski distance using Python The Minkowski distance between two points of n-dimensions is a generic metric and is given by ((x1-y1)p + (x2-y1)p...+(xn - yn)p)1/p. For each value of p, a specialised metric is given. 23 Jul 2025
- 11 Condensed distance matrix - Calculating pairwise distances between data-points using SciPy The scipy function pdist() from the spatial module returns pairwise distanced between data-points as a condensed distance matrix in a one-dimensional ndarray. 8 Jul 2025
- 12 Convert a condensed distance matrix into a square matrix using SciPy The squareform() function expands the condensed distance matrix into the square matrix form which has distances in both upper and triangular parts. The main diagonal of the square matrix is all zeros. 15 Jul 2025
- 13 Text To Vectors