cdlib.evaluation.sample_expected_sim

cdlib.evaluation.sample_expected_sim(first_partition: object, second_partition: object, measure: str = 'jaccard_index', random_model: str = 'perm', n_samples: int = 1, keep_samples: bool = False) MatchingResult

此函数计算从六种随机模型之一绘制的聚类之间所有成对比较的预期相似度。

注意

聚类2被认为是单边期望的黄金标准聚类

Parameters:
  • first_partition – NodeClustering 对象

  • second_partition – NodeClustering 对象

  • measure – 要评估的相似性度量。必须是 [ecs, jaccard_index, rand_index, fowlkes_mallows_index, classification_error, czekanowski_index, dice_index, sorensen_index, rogers_tanimoto_index, southwood_index, mi, rmi, vi, geometric_accuracy, overlap_quality, sample_expected_sim] 之一

  • random_model

    使用的随机模型:

    ’all’在所有聚类集合上的均匀分布

    n_elements

    ’all1’从所有聚类集合上的均匀分布中进行单边选择

    n_elements

    ’num’在n_clusters中的所有聚类集合上的均匀分布

    n_elements

    ’num1’从n_clusters中的所有聚类集合上的均匀分布中进行单边选择

    n_elements

    ’perm’ : 固定聚类大小序列的排列模型

    ’perm1’从固定聚类大小序列的排列模型中进行单边选择

    与’perm’相同

  • n_samples – 用于确定预期相似性的随机聚类样本数量。

  • keep_samples – 如果为True,返回相似性样本本身,否则返回它们的平均值。

Returns:

匹配结果对象

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.sample_expected_sim(louvain_communities,leiden_communities)

注意

该函数需要安装clusim库。您可以通过pip安装:pip install clusim