使用嵌入查找相似节点时根据“权重”对邻居进行排序

问题描述 投票:0回答:0

我有一系列三胞胎,例如:

[Patient1, affected, disease1],
[Patient1, affected, disease2],
[Patient1, affected, disease5],
[Patient2, affected, disease2],
[Patient1, affected, disease4]
...

我已将此数据导入 python 图形库 networkx(Digraph() 对象),从那里我应用 Node2Vec() 算法来提取所有“患者”的节点嵌入,并在嵌入上运行余弦相似度我得到最相似的给特定患者的患者。 到这里为止一切正常,但是我想知道对于每个相似的患者,哪些邻居会为该相似性分数增加更多的“权重”或“价值”。 换句话说,如果我的目标患者是:

patient20 with neighbors [disease1, disease20, disease24, disease40]

我和这个 patient20 最相似的病人是:

patient34 with neighbors [disease4, disease6, disease24]

我想按重要性顺序检索这个相似患者的邻居,在这种情况下它看起来像这样:

patient34 with neighbors [disease24, disease4, disease6]  

由于疾病 24 存在于两者中,因此可以安全地假设它是该患者的最大贡献者,与所提供的患者 20 最相似。

这怎么可能?首选使用 networkx 的方法,但不是必需的。

python networkx embedding cosine-similarity
© www.soinside.com 2019 - 2024. All rights reserved.