Skip to content

Commit

Permalink
Added tanimoto distance calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
JaksaVucicevic committed Feb 22, 2012
1 parent 9a15888 commit b543ba8
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions receng.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,15 @@ def pearson(self,r1,r2):
else :
return 0

# def tanimoto(self,r1,r2):

def tanimoto(self,r1,r2):
v1 = numpy.array(self.matrix[:,r1])
v2 = numpy.array(self.matrix[:,r2])
a = 0.
o = 0.
for i in range(self.NP) :
if v1[i]>=0 and v2[i]>0 : a += 1.
if v1[i]>=0 or v2[i]>0 : o += 1.
return a/o


engine = Engine()
Expand All @@ -77,3 +84,4 @@ def pearson(self,r1,r2):
print engine.matrix
print engine.similarity(2,4)
print engine.pearson(2,3)
print engine.tanimoto(2,3)

0 comments on commit b543ba8

Please sign in to comment.