-
Hi, great library! I'm having an issue with implementing some link prediction algorithms. For example, currently, I'm trying graphSage - exactly the same way as it is on the Stellargraph website (website), while I've previously applied the training-test-validation set divisions code (also using the same way as on the website) and saved them. I've saved the training and test graphs as networkX gml files. To run the graphSage as in the example I'm reading the networkX graph and feeding it in. When I do that, I receive an error: raise TypeError("Graph must be a StellarGraph or StellarDiGraph object.") When I convert the networkX graphs into StellarGraph using the following code:
this time I'm receiving RuntimeError: This StellarGraph has no numeric feature attributes for nodesNode features are required for machine learning My graph is fine, here is what graph.info returns after Stellargaph.from_networkx conversion: StellarGraph: Undirected multigraph Node types: Edge types: So, the graph is legitimate, it just doesn't have features other than weights. Why am I receiving this error, and why having some kind of a feature other than weight or simply the existence of a link is necessary if that's the reason why I'm getting this error? Thank you so much in advance. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Hi, thanks for asking a question. The GraphSAGE algorithm relies on nodes having feature vectors. For example, if your nodes represent bank accounts, they might have features like "date opened" and "balance". The algorithm needs these features in order to learn anything, because it performs sampling and aggregation on these features directly. One approach is to add a dummy one-hot encoded node feature, representing the node identity. However, this will require a square matrix of features of size (number of nodes)2, which is 70.5 billlion in this case, and so not feasible. (StellarGraph doesn't support sparse features at the moment.) The recommended approach is to choose a different algorithm: other algorithms within StellarGraph that do not need node features, and instead can use just the node label directly. These are listed in https://stellargraph.readthedocs.io/en/stable/demos/#find-a-demo-for-an-algorithm, as the algorithms with an empty "Node features" column, such as GraphWave or Node2Vec. |
Beta Was this translation helpful? Give feedback.
-
can we add feature in stealler graph using any library . |
Beta Was this translation helpful? Give feedback.
Hi, thanks for asking a question.
The GraphSAGE algorithm relies on nodes having feature vectors. For example, if your nodes represent bank accounts, they might have features like "date opened" and "balance". The algorithm needs these features in order to learn anything, because it performs sampling and aggregation on these features directly. One approach is to add a dummy one-hot encoded node feature, representing the node identity. However, this will require a square matrix of features of size (number of nodes)2, which is 70.5 billlion in this case, and so not feasible. (StellarGraph doesn't support sparse features at the moment.)
The recommended approach is to choose a different algori…