本文整理汇总了Python中BitVector.jaccard_distance方法的典型用法代码示例。如果您正苦于以下问题:Python BitVector.jaccard_distance方法的具体用法?Python BitVector.jaccard_distance怎么用?Python BitVector.jaccard_distance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BitVector
的用法示例。
在下文中一共展示了BitVector.jaccard_distance方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: print
# 需要导入模块: import BitVector [as 别名]
# 或者: from BitVector import jaccard_distance [as 别名]
print(bv) # 101101
print("\nTesting count_bits_sparse():")
bv = BitVector(size=2000000)
bv[345234] = 1
bv[233] = 1
bv[243] = 1
bv[18] = 1
bv[785] = 1
print("The number of bits set: " + str(bv.count_bits_sparse())) # 5
print("\nTesting Jaccard similarity and distance and Hamming distance:")
bv1 = BitVector(bitstring='11111111')
bv2 = BitVector(bitstring='00101011')
print("Jaccard similarity: " + str(bv1.jaccard_similarity(bv2))) # 0.5
print("Jaccard distance: " + str(bv1.jaccard_distance(bv2))) # 0.5
print("Hamming distance: " + str(bv1.hamming_distance(bv2))) # 4
print("\nTesting next_set_bit():")
bv = BitVector(bitstring='00000000000001')
print(bv.next_set_bit(5)) # 13
bv = BitVector(bitstring='000000000000001')
print(bv.next_set_bit(5)) # 14
bv = BitVector(bitstring='0000000000000001')
print(bv.next_set_bit(5)) # 15
bv = BitVector(bitstring='00000000000000001')
print(bv.next_set_bit(5)) # 16
print("\nTesting rank_of_bit_set_at_index():")
bv = BitVector(bitstring='01010101011100')
print(bv.rank_of_bit_set_at_index(10)) # 6