cdlib.evaluation.jaccard_index¶
- cdlib.evaluation.jaccard_index(first_partition: object, second_partition: object) MatchingResult¶
This function calculates the Jaccard index between two clusterings.
\[J = \frac{N11}{(N11+N10+N01)}\]- Parameters:
first_partition – NodeClustering object
second_partition – NodeClustering object
- Returns:
MatchingResult object
- Example:
>>> from cdlib import evaluation, algorithms >>> import networkx as nx >>> g = nx.karate_club_graph() >>> louvain_communities = algorithms.louvain(g) >>> leiden_communities = algorithms.leiden(g) >>> evaluation.jaccard_index(louvain_communities,leiden_communities)
- Reference:
Paul Jaccard. The distribution of the flora in the alpine zone. New Phytologist, 11(2):37–50, 1912.
Note
The function requires the clusim library to be installed. You can install it via pip: pip install clusim