这里写自定义目录标题
RDKIT 中用的Tanimoto similarity 计算
python 实现代码如下
import numpy as np
def tanimoto_coefficient(p_vec, q_vec):
"""
This method implements the cosine tanimoto coefficient metric
:param p_vec: vector one
:param q_vec: vector two
:return: the tanimoto coefficient between vector one and two
"""
pq = np.dot(p_vec, q_vec)
p_square = np.linalg.norm(p_vec, ord=2)**2
q_square = np.linalg.norm(q_vec, ord=2)**2
return pq / (p_square + q_square - pq)
公式:
T
(
x
,
y
)
T(x,y)
T(x,y) =
x
y
∣
∣
x
∣
∣
2
+
∣
∣
y
∣
∣
2
−
x
y
{xy} \over {||x||^2 + ||y||^2 - xy}
∣∣x∣∣2+∣∣y∣∣2−xyxy
网上看到的文章,分母部分都忘了平方。