Giter VIP home page Giter VIP logo

tnodeembed's Introduction

tNodeEmbed

This repository provides a reference implementation of tNodeEmbed as described in the paper:

Node Embedding over Temporal Graphs.
Uriel Singer, Ido Guy and Kira Radinsky.
International Joint Conferences on Artificial Intelligence, 2019.
https://www.ijcai.org/proceedings/2019/0640.pdf

The tNodeEmbed algorithm learns temporal representations for nodes in any (un)directed, (un)weighted temporal graph. For Further explanation of tNodeEmbed please visit it's blog in Medium.

Requirements

  • python>=3.6
  • networkx
  • numpy
  • tqdm
  • pandas
  • keras
  • matplotlib
  • node2vec
  • sklearn

Basic Usage

Start by creating a networkx graph where each edge has a 'time' attribute. Given a DataFrame with 'source','target' and 'time' columns, you can execute the following:

graph_nx = loader.dataset_loader.df2graph(graph_df, source, target, time, create_using=nx.Graph())

Continue by initializing a tNodeEmbed model by writing:

tnodeembed = models.tNodeEmbed(graph_nx, task=task, dump_folder=dump_folder)

Where task can be either 'temporal_link_prediction' or 'node_classification'. The dump_folder is for future runnning times.

Then create your task dataset by writing:

X, y = tnodeembed.get_dataset()

Where X and y are dictionaries with keys 'train' and 'test'.

Training time!

X['train'] = graph_utils.nodes2embeddings(X['train'], tnodeembed.graph_nx, tnodeembed.train_time_steps)
tnodeembed.fit(X['train'] ,y['train'])

Or by using a generator:

steps_per_epoch = ceil(len(X['train']) / batch_size)
generator = loader.dataset_generator(X['train'], y['train'], tnodeembed.graph_nx, tnodeembed.train_time_steps, batch_size=batch_size)
tnodeembed.fit_generator(generator, steps_per_epoch)

And prediction:

X['test'] = graph_utils.nodes2embeddings(X['test'], tnodeembed.graph_nx, tnodeembed.train_time_steps)
tnodeembed.predict(X['test'])

Or by using a generator:

steps = ceil(len(X['test']) / batch_size)
generator = loader.dataset_generator(X['test'], y['test'], tnodeembed.graph_nx, tnodeembed.train_time_steps, batch_size=batch_size, shuffle=False)
tnodeembed.predict_generator(generator, steps)

A full flow example and comparission to node2vec can be found in main.py

Citing

If you find tNodeEmbed useful for your research, please consider citing the following paper:

@inproceedings{ijcai2019-640,
  title     = {Node Embedding over Temporal Graphs},
  author    = {Singer, Uriel and Guy, Ido and Radinsky, Kira},
  booktitle = {Proceedings of the Twenty-Eighth International Joint Conference on
	       Artificial Intelligence, {IJCAI-19}},
  publisher = {International Joint Conferences on Artificial Intelligence Organization},             
  pages     = {4605--4612},
  year      = {2019},
  month     = {7},
  doi       = {10.24963/ijcai.2019/640},
  url       = {https://doi.org/10.24963/ijcai.2019/640},
}

Miscellaneous

Please send any questions you might have about the code and/or the algorithm to [email protected].

Note: This is only a beta version of the tNodeEmbed algorithm. There are other amendments that need to be made before this work can be relied upon.

tnodeembed's People

Contributors

urielsinger avatar

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.