Skip to content

reddavis/Distance-Measures

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Distance Measures

A bunch of distance measures that extend Array.

Install

gem sources -a http://gemcutter.org
sudo gem install distance_measures

How to use

a = [1,1]
b = [2,2]

a.euclidean_distance(b)

a.cosine_similarity(b)

a.jaccard_index(b)

a.jaccard_distance(b)

a.binary_jaccard_index(b)

a.binary_jaccard_distance(b)

a.tanimoto_coefficient(b)

a.haversine_distance(b)

This may or may not be the complete list, best thing is to check the source code.

There are also a couple bonus methods:

a.dot_product(b)

a.sum_of_squares

a.intersection_with(b)

a.union_with(b)

# When your dealing with 1's and 0's
a.binary_intersection_with(b)

a.binary_union_with(b)

Copyright © 2010 reddavis. See LICENSE for details.