scipy.spatial.
distance_matrix#
- scipy.spatial.distance_matrix(x, y, p=2, threshold=1000000)[Quelle]#
Berechnet die Distanzmatrix.
Gibt die Matrix aller paarweisen Distanzen zurück.
- Parameter:
- x(M, K) array_like
Matrix aus M Vektoren in K Dimensionen.
- y(N, K) array_like
Matrix aus N Vektoren in K Dimensionen.
- pfloat, 1 <= p <= infinity
Welche Minkowski-p-Norm verwendet werden soll.
- thresholdpositive int
Wenn
M * N * K> threshold, verwendet der Algorithmus eine Python-Schleife anstelle großer temporärer Arrays.
- Rückgabe:
- result(M, N) ndarray
Matrix, die die Distanz von jedem Vektor in x zu jedem Vektor in y enthält.
Beispiele
>>> from scipy.spatial import distance_matrix >>> distance_matrix([[0,0],[0,1]], [[1,0],[1,1]]) array([[ 1. , 1.41421356], [ 1.41421356, 1. ]])