예제 #1
0
 def testOtherSims(self):
     """ test other similarity measures
 """
     v1 = klass(10)
     v1[0] = 1
     v1[2] = 1
     v1[6] = 1
     v2 = klass(10)
     v2[0] = 1
     v2[3] = 1
     v2[6] = 1
     assert feq(cDataStructs.CosineSimilarity(v1, v2), .6667)
     assert feq(cDataStructs.KulczynskiSimilarity(v1, v2), .6667)
     assert feq(cDataStructs.DiceSimilarity(v1, v2), .6667)
     assert feq(cDataStructs.SokalSimilarity(v1, v2), .3333)
     assert feq(cDataStructs.McConnaugheySimilarity(v1, v2), .3333)
     assert feq(cDataStructs.AsymmetricSimilarity(v1, v2), .6667)
     assert feq(cDataStructs.BraunBlanquetSimilarity(v1, v2), .6667)
     assert feq(cDataStructs.RusselSimilarity(v1, v2), .2000)
     assert feq(cDataStructs.RogotGoldbergSimilarity(v1, v2), .7619)
예제 #2
0
 def testQuickSims(self):
     """ the asymmetric similarity stuff (bv,pkl)
 """
     v1 = self.klass(10)
     v1[0] = 1
     v1[2] = 1
     v1[6] = 1
     v2 = self.klass(10)
     v2[0] = 1
     v2[3] = 1
     v2[6] = 1
     pkl = v2.ToBinary()
     v2 = pkl
     assert feq(cDataStructs.CosineSimilarity(v1, v2), .6667)
     assert feq(cDataStructs.KulczynskiSimilarity(v1, v2), .6667)
     assert feq(cDataStructs.DiceSimilarity(v1, v2), .6667)
     assert feq(cDataStructs.SokalSimilarity(v1, v2), .3333)
     assert feq(cDataStructs.McConnaugheySimilarity(v1, v2), .3333)
     assert feq(cDataStructs.AsymmetricSimilarity(v1, v2), .6667)
     assert feq(cDataStructs.BraunBlanquetSimilarity(v1, v2), .6667)
     assert feq(cDataStructs.RusselSimilarity(v1, v2), .2000)
     assert feq(cDataStructs.RogotGoldbergSimilarity(v1, v2), .7619)