Jaccard similarity score ValueError: multiclass-multioutput is not supported Python

Jaccard similarity score ValueError: multiclass-multioutput is not supported Python

我想计算两个列表或词组的 jaccard 索引。 我的值如下:

list1: [('Golden', 0.35036513209342957), ('waking', 0.3429567813873291), ('Keep', 0.34041523933410645), ('Lying', 0.33063751459121704), ('washed', 0.3259369730949402), ('wedged', 0.32253023982048035), ('enjoyment', 0.32023900747299194), ('mid-December', 0.31836390495300293), ('whispered', 0.3126818835735321), ('jittery', 0.31083038449287415)]

如果我计算 jaccard_similarity_score(list1,list2) 我得到这个错误 ValueError: multiclass-multioutput is not supported

我也尝试过使用这样的集合:

set1=set()
set2=set()

for el in list1:
    set1.add(el[0])
for el in list2:
    set2.add(el[0])
j=jaccard_similarity_score(set1,set2)

但是我得到这个错误ValueError: Expected array-like (array or non-string sequence), got set(['whispered', 'Golden', 'enjoyment', 'washed', 'wedged', 'Keep', 'mid-December', 'jittery', 'waking', 'Lying']) 我做错了什么?

docs 看来你需要这个:

l1 = [i[0] for i in list1]
l2 = [j[0] for j in list2]
j = jaccard_similarity_score(l1,l2)