雅卡尔指数 (Jaccard index)
2020-04-17 本文已影响0人
生信编程日常
雅卡尔指数,或者称为交并比、雅卡尔相似系数,可以用于比较样本集的相似性与多样性。其定义为两个集合交集大小与并集大小之间的比例:



雅卡尔距离(Jaccard distance)则用于量度样本集之间的不相似度,其定义为1减去雅卡尔系数。
比如:
A <- c(0,1,2,5,6)
B <- [0,2,3,4,5,7,9]
jacc_index <- length(intersect(A, B)) / length(union(A, B))
# 即33.33%
当A和B是空集时,定义jaccard index为1。
对于非对称二元属性而言(比如说对于患癌症和不患癌症的属性而言,不患癌症是0,患癌症是1,那么0的数量远远大于1,但是我们却更关注1的数量):
M11 - A和B中都是1;
M01 - A中是0,B中是1;
M10 - A中是1,B中是0;
M00 - 两者都是0.
雅卡尔指数为(由于M00过多不予考虑):
