# turicreate.toolkits.distances.dot_product¶

turicreate.toolkits.distances.dot_product(x, y)

Compute the dot_product between two dictionaries or two lists of equal length. Suppose x and y each contain $$d$$ variables:

$D(x, y) = \frac{1}{\sum_i^d x_i y_i}$

Warning

The ‘dot_product’ distance is deprecated and will be removed in future versions of Turi Create. Please use ‘transformed_dot_product’ distance instead, although note that this is more than a name change; it is a different transformation of the dot product of two vectors. Please see the distances module documentation for more details.

Parameters: x : dict or list First input vector. y : dict or list Second input vector. out : float

Notes

• If the input vectors are in dictionary form, keys missing in one of the two dictionaries are assumed to have value 0.
• Dot product distance is not a metric. This means the ball tree cannot be used to compute nearest neighbors based on this distance.

Examples

>>> tc.distances.dot_product([1, 2, 3], [4, 5, 6])
0.03125
...
>>> tc.distances.dot_product({'a': 2, 'c': 4}, {'b': 3, 'c': 12})
0.020833333333333332