turicreate.toolkits.distances.compute_composite_distance¶
-
turicreate.toolkits.distances.
compute_composite_distance
(distance, x, y)¶ Compute the value of a composite distance function on two dictionaries, typically SFrame rows.
Parameters: - distance : list[list]
A composite distance function. Composite distance functions are a weighted sum of standard distance functions, each of which applies to its own subset of features. Composite distance functions are specified as a list of distance components, each of which is itself a list containing three items:
- list or tuple of feature names (strings)
- standard distance name (string)
- scaling factor (int or float)
- x, y : dict
Individual observations, typically rows of an SFrame, in dictionary form. Must include the features specified by distance.
Returns: - out : float
The distance between x and y, as specified by distance.
Examples
>>> sf = turicreate.SFrame({'X1': [0.98, 0.62, 0.11], ... 'X2': [0.69, 0.58, 0.36], ... 'species': ['cat', 'dog', 'fossa']}) ... >>> dist_spec = [[('X1', 'X2'), 'euclidean', 2], ... [('species',), 'levenshtein', 0.4]] ... >>> d = turicreate.distances.compute_composite_distance(dist_spec, sf[0], sf[1]) >>> print d 1.95286120899