Skip to main content

Wasserstein Weisfeiler-Lehman Graph Kernels

Project description

WWL Package


To install wwl, run the following:

$ pip install cython numpy
$ pip install wwl


WWL can be used to compute the pairwise kernel matrix between a list of Graphs. The kernel function wwl takes as input a list of igraph Graph objects. It can also take their node features (if they are continuously attributed), the number of iterations for the embedding scheme, the value for gamma in the Laplacian kernel, and a flag for sinkhorn approximations.

from wwl import wwl

# load the graphs
graphs = [ for fname in graph_filenames]

# load node features for continuous graphs
node_features = np.load(path_to_node_features)

# compute the kernel
kernel_matrix = wwl(graphs, node_features=node_features, num_iterations=4)

# use in SVM
from sklearn.svm import SVC

train_index, test_index = np.load(train_index_path), np.load(test_index_path)
y = np.load(path_to_labels)
K_train = kernel_matrix[train_index][:,train_index]
K_test = kernel_matrix[test_index][:,train_index]

svm = SVC(kernel='precomputed') # For a Krein SVM, please refer to

y_predict = svm.predict(K_test)

Please see utilities.wwl_custom_grid_search_cv for a custom crossvalidation to cross-validate the number of iterations, gammas in the Laplacian kernel, and other parameters for the SVM.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for wwl, version 0.1.2
Filename, size File type Python version Upload date Hashes
Filename, size wwl-0.1.2-py3-none-any.whl (8.2 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size wwl-0.1.2.tar.gz (7.0 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page