Search code examples
numpynetworkxsvmword2vec

stuck in feeding my SVM after creating my node2vec model


I am trying to do node classification using Node2Vec and SVM on a graph obtained from protein-protein interaction to predict disease genes related to a specific disease. to be accurate. the point is that, I have created a Graph using networkx , my nodes have labels(names of protein) and attributes=0/1(if this protein is causing a disease or not). I applied node2vec on this graph and I have my model. (I don't care about values of p and q at this stage) but I don't know how to proceed and feed it to SVM or more importantly, how to reduce dimensions of my vectorized graph before feeding it to SVM. plus, I don't know if in these vectors, the attributes of my node are included or not. separately however, I have a dictionary called lbls to have my nodes and their value here is small piece of code

node2vec = Node2Vec(G, dimensions=512, workers=4,p=1,q=2)
model = node2vec.fit(window=10, min_count=1, batch_words=4)

Solution

  • node2vec is an unsupervised node embedding method, which is based on Word2Vec. Have a look at the snap documentation for a brief description of the model. It will not use any of your attributes/features to create the embedding. It uses a shallow encoding, which are directly learned using a random walk based objective function. For details look at the paper or check the Stanford Lecture about node embeddings, which covers in detail Node2Vec. Your embedding dimension is currently 512 (for the node embedding of node2vec), which you probably can reduce.