다음과 같이 두 개의 목록이 있습니다.파이썬에서 scipy를 사용하여 jaccard 거리를 계산하십시오.
list1 =[[0.0, 0.75, 0.2], [0.0, 0.5, 0.7]]
list2 =[[0.9, 0.0, 0.8], [0.0, 0.0, 0.8], [1.0, 0.0, 0.0]]
는 I는리스트 1의 X리스트 2의 인 Jaccard 거리 행렬을 얻고 싶은 (즉, 매트릭스 (6)의 값을 포함하는 2 × 3)
For example;
[0.0, 0.75, 0.2] in list1 with all the three lists in list2
[0.0, 0.5, 0.7] in list1 with all the three lists in list2
I 실제로 모두 pdist
및 cdist
시도. 그러나 각각 다음과 같은 오류가 발생합니다. TypeError: pdist() got multiple values for argument 'metric'
및 ValueError: XA must be a 2-dimensional array.
.
이 문제를 해결하는 데 도움을주십시오.
입력으로 포장하는'np.atleast_2d'을 시도해 보셨습니까? – Divakar