hemanta
hemanta

Reputation: 1510

Using graph properties as an input in Neural Network

I have almost 1000 of pandas DataFrame, which I converted into graphs. Now I can access edges and nodes of those graphs. For one DataFrame it looks like following:

nx.edges(FG)

Out[59]: EdgeView([('Dy0O7', 'Dy1O6'), ('Dy0O7', 'Dy2O6'), ('Dy0O7', 'Dy3O7'), ('Dy0O7', 'Dy4O6'), ('Dy1O6', 'Dy3O7'), ('Dy1O6', 'Dy5O6'), ('Dy2O6', 'Dy4O6'), ('Dy3O7', 'Dy4O6'), ('Dy3O7', 'Dy5O6')])

nx.nodes(FG)

Out[61]: NodeView(('Dy0O7', 'Dy1O6', 'Dy2O6', 'Dy3O7', 'Dy4O6', 'Dy5O6'))

Also I can have adjancy view, which gives the information about connected nodes with corresponding weights.

FG.adj

Out[64]: AdjacencyView({'Dy0O7': {'Dy1O6': {'weight': 3.0}, 'Dy2O6': {'weight': 1.0}, 'Dy3O7': {'weight': 2.0}, 'Dy4O6': {'weight': 1.0}}, 'Dy1O6': {'Dy0O7': {'weight': 3.0}, 'Dy3O7': {'weight': 1.0}, 'Dy5O6': {'weight': 1.0}}, 'Dy2O6': {'Dy0O7': {'weight': 1.0}, 'Dy4O6': {'weight': 1.0}}, 'Dy3O7': {'Dy0O7': {'weight': 2.0}, 'Dy1O6': {'weight': 1.0}, 'Dy4O6': {'weight': 3.0}, 'Dy5O6': {'weight': 1.0}}, 'Dy4O6': {'Dy0O7': {'weight': 1.0}, 'Dy2O6': {'weight': 1.0}, 'Dy3O7': {'weight': 3.0}}, 'Dy5O6': {'Dy1O6': {'weight': 1.0}, 'Dy3O7': {'weight': 1.0}}})

I want to use such graph properties as an input in Machine learning algorithm such as NN, How can we do that?

Upvotes: 0

Views: 141

Answers (1)

Amir
Amir

Reputation: 16597

There are a bunch of algorithms out there to convert Graph into feature vectors. Two famous examples are:

Their implementation exists on GitHub.

The underlying idea between these methods are almost the same: 1) Random walk 2) generate some sequences 3) word2vec (skip-gram) or other DL methods 4) use output as a feature vector in other Task.

enter image description here

Upvotes: 3

Related Questions