StellarGraph

Node_feature extraction for hetrogenous graphs

We are working with Graph data in Ntriple format(.nt files). We are able to convert the Ntriple data in to graphMl format before feeding it to StellarGraph .
However, we are facing issues with node_feature extraction from the .graphml.

Below is the .graphml data,

<?xml version='1.0' encoding='utf-8'?> ... ...


We are using ‘rdflib_to_networkx_multidigraph’ to convert the Ntriple data in to .graphml.
Can you please let us know, how can we extract the node_features for the above graph data.
Thanks!

Hi sysmik,

thank you for using our library.

In order to help you, we need a bit more information from you.

The graphml data was not included in your message, can you try sending it again?

Also, at what point in your workflow are you trying to extract the node features? Is that when creating the StellarGraph object, before or after?

Regards,

P.

Hi Elinas,
Thanks for your reply. I uploaded the graphml file image below and one in my initial message due to upload restrictions .
While creating the StellarGraph object, I am trying to pass node_features along with the NetworkX Graph object (Gs = StellarGraph(nx_graph, node_features=node_data))

testnode_graphml_file

Hi susmik,

I want to understand the data stored with nodes in your networkx object.

What is the output of the following statement?

print(list(nx_graph.nodes(data=True))[0])

Also, in your statement Gs = StellarGraph(nx_graph, node_features=node_data), how was the object node_data created? Is it a Pandas Dataframe?

Regards,

P.

Hi elinas,

print(list(nx_graph.nodes(data=True))[0])
output : (rdflib.term.URIRef(‘http://openflights.org/Route/IB_BCN_RNS’), {})

And my query was, how to extract the node_features(or node_data) for the above graph.

Thanks!

Hi susmik,

based on the above output, your graph doesn’t have any data associated with the nodes so there is nothing to extract.

If you are trying to solve a node classification problem for a graph with no node attributes using the metapath2vec algorithm, then you can just create the StellarGraph object simply using,

Gs = StellarGraph(nx_graph)

Regards,

P.

Hi Elinas,

May I know the difference between hinsage and metapath2vec algorithm with respect to heterogeneous graphs.

Also, I don’t see any sample codes for metapath2vec algorithm. can you please point me to one.
Thanks!

Hi,

both methods can be used for representation learning on heterogeneous graphs.

HinSAGE is our extension of the well known GraphSAGE algorithm published by W. L. Hamilton et al, http://papers.nips.cc/paper/6703-inductive-representation-learning-on-large-graphs

You can find a HinSAGE demo at https://github.com/stellargraph/stellargraph/tree/develop/demos/node-classification/hinsage

Metapath2vec is an extension of the node2vec algorithm. The metapath2vec paper by Y. dong et al can be downloaded from https://dl.acm.org/citation.cfm?id=3098036

You can find a metapath2vec demo at https://github.com/stellargraph/stellargraph/tree/develop/demos/embeddings

Regards,

P.

Hi elinas,
metapath2vec generates the embeddings for heterogeneous graphs. The metapath2vec example under demos doesn’t have a node classification example.
Can you please let me know, how can I use metapath2vec embedding’s in node classification

Thanks!

Hi susmik,

once you have calculated, using metapath2vec, an embedding vector for each node in your graph then you can use these vectors as input to any classification algorithm. You can have a look at our node2vec node classification demo of how to use the embeddings to solve a downstream task using Logistic Regression. Solving the classification problem starts at cell 29 in the following notebook,

Regards,

P.