turicreate.toolkits.distances.squared_euclidean¶
-
turicreate.toolkits.distances.
squared_euclidean
(x, y)¶ Compute the squared Euclidean distance between two dictionaries or two lists of equal length. Suppose x and y each contain \(d\) variables:
\[D(x, y) = \sum_i^d (x_i - y_i)^2\]Parameters: - x : dict or list
First input vector.
- y : dict or list
Second input vector.
Returns: - out : float
Squared Euclidean distance between x and y.
Notes
- If the input vectors are in dictionary form, keys missing in one of the two dictionaries are assumed to have value 0.
- Squared Euclidean distance does not satisfy the triangle inequality, so it is not a metric. This means the ball tree cannot be used to compute nearest neighbors based on this distance.
References
Examples
>>> tc.distances.squared_euclidean([1, 2, 3], [4, 5, 6]) 27.0 ... >>> tc.distances.squared_euclidean({'a': 2, 'c': 4}, ... {'b': 3, 'c': 12}) 77.0