lambda-ml.distance

Functions that compute measures of distance between values.

cosine

(cosine x y)(cosine x y d)

Returns the cosine distance between two points by subtracting the cosine similarity from 1. Assumes that both points are represented as sequences of the same dimension. Given a dimension d, returns the distance between two points as if the values for all other dimensions were set to zero.

euclidean

(euclidean x y)(euclidean x y d)

Returns the Euclidean distance (squared) between two points. Assumes that both points are represented as sequences of the same dimension. Given a dimension d, returns the distance between two points as if the values for all other dimensions were set to zero.

haversine

(haversine [lat1 lng1] [lat2 lng2])(haversine x y d)

Returns the great-circle distance between two points represented as geographic coordinates. Given a dimension d, returns the distance between the two points as if the value for the other dimension was set to zero.

jaccard

(jaccard x y)(jaccard x y d)

Returns the Jaccard distance between two points by subtracting the Jaccard similarity coefficient from 1. Assumes that both points are represented as sequences of the same dimension. Given a dimension d, returns the distance between two points as if the values for all other dimensions were set to zero.