Giter VIP home page Giter VIP logo

jwalk's Introduction

jwalk

Build Status Documentation Status

jwalk performs random walks on a graph and learns representations for nodes using Word2Vec. It also has options to train existing models online and specify weights.

Install

pip install -U jwalk

Build

make build

Usage

jwalk -i tests/data/karate.edgelist -o karate.emb --delimiter=' '

To see the full list of options:

jwalk --help

Prompt parameters:
  debug:            drop a debugger if an exception is raised
  delimiter:        delimiter for input file
  embedding-size:   dimension of word2vec embedding (default=200)
  has-header:       boolean if csv has header row
  help (-h):        argparse help
  input (-i):       file input (edgelist of 2/3 cols or adjacency matrix)
  log-level (-l)    logging level (default=INFO)
  model (-m):       use a pre-existing model
  num-walks (-n):   number of of random walks per graph (default=1)
  output (-o):      file output
  stats:            boolean to calculate walk statistics [requires pandas]
  undirected:       make graph undirected
  walk-length:      length of random walks (default=10)
  window-size:      word2vec window size (default=5)
  workers:          number of workers (default=multiprocessing.cpu_count)

Input File

The input file can be of the following formats:

  • Edgelist: CSV with 2 or 3 columns denoting the source, target and (optional) weight. There are CLI options to specify the delimiter and whether the file has a header (default=False). The CSV file is loaded using numpy if pandas is not installed. We strongly recommend using pandas to load the CSV as it's a lot faster.
  • Graph: If the file has an extension that is ".npz", jwalk will assume that it is a SciPy CSR matrix. Included must be keys of data, indices, indptr, shape and labels (default=None) where labels are the node labels. For an example, see tests/data/karate.npz.

Test

Running unit tests:

make test

Running linter:

make lint

Running tox:

make test-all

Blog

Read more about jwalk in our blog post here: https://www.jwplayer.com/blog/deepwalk-recommendations/

License

Apache License 2.0

References

  • [paper]: arXiv:1403.6652 [cs.SI] "DeepWalk: Online Learning of Social Representations"
  • [paper]: arXiv:1607.00653 [cs.SI] "node2vec: Scalable Feature Learning for Networks"

jwalk's People

Contributors

dshore avatar ksindi avatar yungster avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jwalk's Issues

the emb result are not displayed properly

<80>^Bcjwalk.skipgram
2 Skipgram
3 q^A)<81>q^B}q^C(U^Dloadq^Dcgensim.utils
4 call_on_class_only
5 q^EU^Ktrain_countq^FK^AU^Kbatch_wordsq^GM^P'U cbow_meanq^HK^AU^Frandomq cnumpy.random
6 __RandomState_ctor
7 q
8 )Rq^K(U^GMT19937q^Lcnumpy.core.multiarray
9 reconstruct
10 q^Mcnumpy
11 ndarray
12 q^NK^@<85>U^Ab<87>Rq^O(K^AMp^B<85>cnumpy
13 dtype
14 q^PU^Bu4K^@k^A<87>Rq^Q(K^CU^A<NNNJÿÿÿÿJÿÿÿÿK^@tb<89>TÀ ^@^@<9a>z´<9c>^H<91>ѱ^W^W (á0lðæÀ@/=<^\Å»H<89>^E2?fj;<86><84>È£ÿ+<8f><8a><97>7À²<91 >BD½Ô<90>áÌÀ"tÑ^L^A<9f>J_ç<9a>a^Zô6&^B7P<8f>0<96>ï?^R<­TrPI^@<8d><9f>uêqúF^FwÄÐ^BÓu@Óû?6;ÚÃwëe~^X^ElTJ;±Ôqè^¥üÄÍ»ÊæÕ<NqÀ^
»9¾/rÞÃû<85>c<9d ><Á<97>¸©$Oßó¤<9f><88><89>Û^A<81>÷fB^{à<8f>Ç^C1<97><88>õ
15 ²ý¯a%ç^O¼úQ¯V|]oñ¼^@3$>^]^^<84>^V¹¢#
<9c>Æ=|â­+}y¬º<9e>¡t<91>¥£Â§<93><99>-X´ñÿ<91>Õ ^[ã<8d>Á:®9R^X^Zö5T¬Ìµwpz

while the deepwalks generate the result like this:
34 10 34 -0.006326 0.201134 -0.550136 -0.086736 0.179594 -0.374418 -0.789379 0.624164 0.586701 -0.151844 1 0.094504 0.043796 -0.229939 0.156263 -0.291131 -0.483646 -0.126931 -0.573272 -0.801995 -0.569402 33 -0.355898 0.506667 0.044414 -0.187979 -0.304238 -0.409748 -0.842301 0.836314 0.630177 -0.204261 3 0.722075 0.166128 -0.633459 0.433687 0.003020 0.285339 -0.443300 0.170543 -0.330985 0.169615 2 -0.020249 0.053541 -0.809832 0.065876 -0.453971 -0.028110 -0.347451 0.359109 -1.024664 -0.748024 4 0.104225 -0.085589 -0.371608 0.237721 -0.230345 -0.230907 -0.052962 0.588910 -1.375630 -0.303069
finally, the input adjmatrix has to be put each egde in single row, waste memory

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.