Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

How to detect communities and measure similarity between communities? #5

Open
rann1018 opened this issue Feb 11, 2020 · 5 comments
Open

Comments

@rann1018
Copy link

No description provided.

@rann1018 rann1018 changed the title How to detect communities and How to detect communities and measure similarity between communities? Feb 11, 2020
@rann1018
Copy link
Author

Hello,
Thanks a lot for your work.
I run your code successfully and found that the final .txt file only contained node embedding feature.
How can I get detected communities and how to measure the similarity between communities?
I look forward to your reply.

@abegehr
Copy link

abegehr commented Feb 29, 2020

The detected communities, as represented by a Gaussian Mixture Model (GMM), are accessible at com_learner.g_mixture. See https://github.com/andompesta/ComE/blob/master/ADSCModel/community_embeddings.py#L24

You can add some code to the end of main.py to extract info from the communities after running ComE.
To compute predicted labels for nodes (community assignment):

labels_pred = np.array(com_learner.g_mixture.predict(model.node_embedding)).astype(int)

And get the GMM's means and covariances with com_learner.g_mixture.means_ and com_learner.g_mixture.covariances_.

You can also plot communities, nodes, and community assignments using plot_utils. See an example here: https://github.com/abegehr/ComE_BGMM/blob/master/main.py#L166

@rann1018
Copy link
Author

Thanks a lot for your help!

@kostaspm
Copy link

The detected communities, as represented by a Gaussian Mixture Model (GMM), are accessible at com_learner.g_mixture. See https://github.com/andompesta/ComE/blob/master/ADSCModel/community_embeddings.py#L24

You can add some code to the end of main.py to extract info from the communities after running ComE. To compute predicted labels for nodes (community assignment):

labels_pred = np.array(com_learner.g_mixture.predict(model.node_embedding)).astype(int)

And get the GMM's means and covariances with com_learner.g_mixture.means_ and com_learner.g_mixture.covariances_.

You can also plot communities, nodes, and community assignments using plot_utils. See an example here: https://github.com/abegehr/ComE_BGMM/blob/master/main.py#L166

I assume the order of the detected communities on the labels_pred is adjacent to the nodes of model.vocab ? I need to collect the communities to perform various fairness definitions on nodes attributes.

@abegehr
Copy link

abegehr commented Jan 20, 2023

@kostaspm, I assume you're referencing this line: labels_pred = np.array(com_learner.g_mixture.predict(model.node_embedding)).astype(int)
The labels in labels_pred are indexes parallel to the nodes in model.node_embedding. I would assume that model.node_embedding are indexed parallel to model.vocab, since the Node2Vec sentences are generated from model.vocab:

def prepare_sentences(model, paths):

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants