ash_model.multiego.jaccard_similarity¶
- ash_model.multiego.jaccard_similarity(multiego1, multiego2)[source]¶
Compute the Jaccard similarity between two Multi-Ego Networks.
The Jaccard similarity is defined as the size of the intersection divided by the size of the union of the two Multi-Ego Network hyperedge sets.
- Parameters:
- Returns:
Jaccard similarity score in [0, 1]. Returns 0.0 if both Multi-Ego Networks are empty.
- Return type:
Examples
>>> multiego1 = [{1, 2}, {2, 3}, {1, 3}] >>> multiego2 = [{1, 2}, {3, 4}] >>> sim = jaccard_similarity(multiego1, multiego2) >>> print(f"Jaccard similarity: {sim:.3f}")