<commit_before>Weisfeiler-Lehman Neural Machine for Link Prediction
====================================================

Usage
----
The first deep learning approach for link prediction (not by embedding), which extracts links' enclosing subgraphs as input to neural networks to learn their formation mechanisms. For more information, see the following paper:
> <NAME> and <NAME>, Weisfeiler-Lehman Neural Machine for Link Prediction, Proc. ACM SIGKDD Conference on Knowledge Discovery and Data Mining (KDD-17). [\[Video\]](https://www.youtube.com/watch?v=dRC4T2gABS8&t=43s) [\[PDF\]](http://www.cse.wustl.edu/~muhan/papers/KDD_2017.pdf)

Run Main.m in MATLAB to do the link prediction experiments.

How to run
----------

You need to install liblinear for saving .mat data to libsvm format so that Torch can read them.

    cd software/
    wget -O liblinear.tar.gz http://www.csie.ntu.edu.tw/~cjlin/cgi-bin/liblinear.cgi?+http://www.csie.ntu.edu.tw/~cjlin/liblinear+tar.gz
    tar xvzf liblinear.tar.gz
    cd liblinear-2.1/
    make

This will install liblinear. Then, in MATLAB, cd to "software/liblinear-2.1/matlab/", type "make" to install the MATLAB interface. Please also change the names of "train.mexa64" and "predict.mexa64" to "liblinear_train.mexa64" and "liblinear_predict.mexa64" respectively if you want to train a logistic regression model instead of neural network.

The "WLNM.m" file contains three models: 1) logistic regression, 2) neural network by Torch, and 3) neural network by MATLAB. Please change _model_ in the file according to your need.

If you want to run the Torch neural network (features GPU acceleration) in your Linux server, and your MATLAB cannot succesfully load cunn, please try the following command to start MATLAB. This will replace the MATLAB's libstdc++.so.6 with the system's default one (for successfully loading cunn of Torch inside MATLAB).

    LD_PRELOAD="/usr/lib64/libstdc++.so.6" matlab 

In MATLAB, type

    Main

to run the experiments. By default, you will run WLNM on the smallest network, USAir, for 1 time. Modify: _numberOfExperiment_, _dataname_, and _method_ in "Main.m", in order to run repeated experiments on all datasets, and compare all link prediction methods.

You may also modify "WLNM.m" in order to only store the training and testing data without running Torch, and use your own neural network programs to train and test on them.

Requirements
------------

Torch library _nnsparse_ is required to load data in libsvm format. Install it by:
    
    luarocks install --local nnsparse

MATLAB Toolbox Bioinformatics is required to calculate graph shortest distance in "graph2vector.m".

To calculate AUC score inside lua, you need to download the metrics package (optional)

    git clone https://github.com/hpenedones/metrics.git
    cd metrics
    luarocks --local make

We use nauty, a graph canonization software to break ties in palette-wl labelings. <commit_msg>add torch.svm requirement in README<commit_after>Weisfeiler-Lehman Neural Machine for Link Prediction
====================================================

Usage
----
The first deep learning approach for link prediction (not by embedding), which extracts links' enclosing subgraphs as input to neural networks to learn their formation mechanisms. For more information, see the following paper:
> <NAME> and <NAME>, Weisfeiler-Lehman Neural Machine for Link Prediction, Proc. ACM SIGKDD Conference on Knowledge Discovery and Data Mining (KDD-17). [\[Video\]](https://www.youtube.com/watch?v=dRC4T2gABS8&t=43s) [\[PDF\]](http://www.cse.wustl.edu/~muhan/papers/KDD_2017.pdf)

Run Main.m in MATLAB to do the link prediction experiments.

How to run
----------

You need to install liblinear for saving .mat data to libsvm format so that Torch can read them.

    cd software/
    wget -O liblinear.tar.gz http://www.csie.ntu.edu.tw/~cjlin/cgi-bin/liblinear.cgi?+http://www.csie.ntu.edu.tw/~cjlin/liblinear+tar.gz
    tar xvzf liblinear.tar.gz
    cd liblinear-2.1/
    make

This will install liblinear. Then, in MATLAB, cd to "software/liblinear-2.1/matlab/", type "make" to install the MATLAB interface. Please also change the names of "train.mexa64" and "predict.mexa64" to "liblinear_train.mexa64" and "liblinear_predict.mexa64" respectively if you want to train a logistic regression model instead of neural network.

The "WLNM.m" file contains three models: 1) logistic regression, 2) neural network by Torch, and 3) neural network by MATLAB. Please change _model_ in the file according to your need.

If you want to run the Torch neural network (features GPU acceleration) in your Linux server, and your MATLAB cannot succesfully load cunn, please try the following command to start MATLAB. This will replace the MATLAB's libstdc++.so.6 with the system's default one (for successfully loading cunn of Torch inside MATLAB).

    LD_PRELOAD="/usr/lib64/libstdc++.so.6" matlab 

In MATLAB, type

    Main

to run the experiments. By default, you will run WLNM on the smallest network, USAir, for 1 time. Modify: _numberOfExperiment_, _dataname_, and _method_ in "Main.m", in order to run repeated experiments on all datasets, and compare all link prediction methods.

You may also modify "WLNM.m" in order to only store the training and testing data without running Torch, and use your own neural network programs to train and test on them.

Requirements
------------

Torch libraries _nnsparse_ and  _svm_ are required to load data in libsvm format. Install it by:
    
    luarocks install --local nnsparse
    luarocks install --local svm

MATLAB Toolbox Bioinformatics is required to calculate graph shortest distance in "graph2vector.m".

To calculate AUC score inside lua, you need to download the metrics package (optional)

    git clone https://github.com/hpenedones/metrics.git
    cd metrics
    luarocks --local make

We use nauty, a graph canonization software to break ties in palette-wl labelings. 
{'fraction_non_alphanumeric': 0.09585361759274803, 'fraction_numerical': 0.01074366291757596, 'mean_word_length': 4.105398457583547, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 4, 'lorem ipsum': 0, 'www.': 8, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '30645', 'n_tokens_mistral': 1812, 'n_tokens_neox': 1677, 'n_words': 756}