Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

How can i get the reconstructed network using bionic? #60

Open
chinaliye opened this issue Jun 7, 2024 · 1 comment
Open

How can i get the reconstructed network using bionic? #60

chinaliye opened this issue Jun 7, 2024 · 1 comment

Comments

@chinaliye
Copy link

I found that the output of bionic was just node embeddings of the fused network. I wonder if there is a simple way to get the edges and weights of the fused network(like the input networks), without changing the code of bionic.

@duncster94
Copy link
Member

Hi, the best way to do this is to compute a pairwise cosine similarity of the embeddings, followed by thresholding the resulting similarities. You can do this using radius_neighbors_graph from sklearn:

def make_net(feat: pd.DataFrame, radius: float) -> nx.Graph:
    net = radius_neighbors_graph(
        feat.values, radius, mode="connectivity", metric="cosine"
    )
    net = nx.from_scipy_sparse_array(net)
    net = nx.relabel_nodes(net, {idx: node for idx, node in enumerate(feat.index)})
    net.remove_edges_from(nx.selfloop_edges(net))
    net.remove_nodes_from(list(nx.isolates(net)))
    return net

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

No branches or pull requests

2 participants