Giter Site home page Giter Site logo

Comments (4)

VHRanger avatar VHRanger commented on July 19, 2024

Yeah, specify n2v = Node2Vec(keep_walks=True) in the node2vec object, then you have access to them in the object after fitting with n2v.walks

from nodevectors.

amjass12 avatar amjass12 commented on July 19, 2024

Thank you, and is there a way if generating the walk without fitting the model? This would speed up the process even more, is there an easy way to do this?

from nodevectors.

VHRanger avatar VHRanger commented on July 19, 2024

You can do it from the CSRGraph object directly, but that returns the node IDs rather than the node names (even if node names are integers, the IDs aren't necessarily the same). So you'd have to map it back, here's a sketch of how to do it, taken from the Node2Vec fit method:

import csrgraph as cg
G =  cg.csrgraph(INPUT_DATA)
walks = G.random_walks()
# Make into dataframe to map ID to names
walks = pd.DataFrame(walks)
# mapping dict node ID -> node name
node_dict = dict(zip(np.arange(len(G.names)), G.names))
for col in walks.columns:
      walks[col] = walks[col].map(node_dict).astype(str)

from nodevectors.

amjass12 avatar amjass12 commented on July 19, 2024

Thank you! This is a good workaround. Appreciate your time

from nodevectors.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.