torcharrow.functional.get_jaccard_similarity¶
- torcharrow.functional.get_jaccard_similarity(input_ids: ListColumn, matching_ids: ListColumn)¶
返回 input_ids 和 matching_ids 之间的 jaccard_similarity。Jaccard 相似度为 |input_ids.intersect(matching_ids)|/|input_ids.union(matching_ids)|
- 参数:
input_ids (第一个 ID 列表) –
matching_ids (第二个 ID 列表) –
示例
>>> import torcharrow as ta >>> from torcharrow import functional >>> input_ids = ta.column([[1, 1, 2, 3],[5,8],[13]]) >>> matching_ids = ta.column([[1,2,3],[2,3],[13,13,13,13,13]]) >>> functional.get_jaccard_similarity(input_ids, matching_ids) 0 0.75 1 0 2 0.2 dtype: Float32(nullable=True), length: 3, null_count: 0