Last active
December 18, 2015 13:29
-
-
Save plusplus/5790169 to your computer and use it in GitHub Desktop.
JaquardCoefficient
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class JaquardCoefficient | |
def similarity( x, y ) | |
raise ArgumentError, "Both sets are empty" if x.empty? && y.empty? | |
return 0.0 if x.empty? || y.empty? | |
(x & y).size.to_f / (x | y).size.to_f | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment