diff --git a/.travis.yml b/.travis.yml index 8703d37..f757ef7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,11 @@ language: python + python: - '3.5' - '3.6' - '3.7' - '3.8' + before_install: - python --version - pip install -U pip @@ -16,9 +18,13 @@ install: - pip install -r requirements.txt - pip install wheel + script: - python setup.py bdist_wheel -- pytest -v --cov-config=.coveragerc --cov-report term --cov=gklearn gklearn/tests/ +- if [ $TRAVIS_PYTHON_VERSION == 3.6 ]; + then pytest -v --cov-config=.coveragerc --cov-report term --cov=gklearn gklearn/tests/; + else pytest -v --cov-config=.coveragerc --cov-report term --cov=gklearn gklearn/tests/ --ignore=gklearn/tests/test_median_preimage_generator.py; + fi after_success: - codecov diff --git a/README.md b/README.md index 7cfdecc..386d9a4 100644 --- a/README.md +++ b/README.md @@ -22,19 +22,53 @@ A Python package for graph kernels, graph edit distances and graph pre-image pro ## How to use? -Simply clone this repository and voilà! Then check [`notebooks`](https://github.com/jajupmochi/graphkit-learn/tree/master/notebooks) directory for demos: +### Install the library + +* Install stable version from PyPI (may not be up-to-date): +``` +$ pip install graphkit-learn +``` + +* Install latest version from GitHub: +``` +$ git clone https://github.com/jajupmochi/graphkit-learn.git +$ cd graphkit-learn/ +$ python setup.py install +``` + +### Run the test + +A series of [tests](https://github.com/jajupmochi/graphkit-learn/tree/master/gklearn/tests) can be run to check if the library works correctly: +``` +$ pip install -U pip pytest codecov coverage pytest-cov +$ pytest -v --cov-config=.coveragerc --cov-report term --cov=gklearn gklearn/tests/ +``` + +### Check examples + +A series of demos of using the library can be found on [Google Colab](https://drive.google.com/drive/folders/1r2gtPuFzIys2_MZw1wXqE2w3oCoVoQUG?usp=sharing) and in the [`example`](https://github.com/jajupmochi/graphkit-learn/tree/master/gklearn/examples) folder. + +### Other demos + +Check [`notebooks`](https://github.com/jajupmochi/graphkit-learn/tree/master/notebooks) directory for more demos: * [`notebooks`](https://github.com/jajupmochi/graphkit-learn/tree/master/notebooks) directory includes test codes of graph kernels based on linear patterns; * [`notebooks/tests`](https://github.com/jajupmochi/graphkit-learn/tree/master/notebooks/tests) directory includes codes that test some libraries and functions; * [`notebooks/utils`](https://github.com/jajupmochi/graphkit-learn/tree/master/notebooks/utils) directory includes some useful tools, such as a Gram matrix checker and a function to get properties of datasets; * [`notebooks/else`](https://github.com/jajupmochi/graphkit-learn/tree/master/notebooks/else) directory includes other codes that we used for experiments. -## List of graph kernels +### Documentation + +The docs of the library can be found [here](https://graphkit-learn.readthedocs.io/en/master/?badge=master). + +## Main contents + +### List of graph kernels * Based on walks * The common walk kernel [1] * Exponential * Geometric - * The marginalized kenrel + * [The marginalized kenrel](https://github.com/jajupmochi/graphkit-learn/blob/master/gklearn/kernels/marginalized.py) * With tottering [2] * Without tottering [7] * The generalized random walk kernel [3] @@ -43,17 +77,29 @@ Simply clone this repository and voilà! Then check [`notebooks`](https://github * Fixed-point iterations * Spectral decomposition * Based on paths - * The shortest path kernel [4] - * The structural shortest path kernel [5] - * The path kernel up to length h [6] + * [The shortest path kernel](https://github.com/jajupmochi/graphkit-learn/blob/master/gklearn/kernels/shortest_path.py) [4] + * [The structural shortest path kernel](https://github.com/jajupmochi/graphkit-learn/blob/master/gklearn/kernels/structural_sp.py) [5] + * [The path kernel up to length h](https://github.com/jajupmochi/graphkit-learn/blob/master/gklearn/kernels/path_up_to_h.py) [6] * The Tanimoto kernel * The MinMax kernel * Non-linear kernels - * The treelet kernel [10] - * Weisfeiler-Lehman kernel [11] - * Subtree + * [The treelet kernel](https://github.com/jajupmochi/graphkit-learn/blob/master/gklearn/kernels/treelet.py) [10] + * [Weisfeiler-Lehman kernel](https://github.com/jajupmochi/graphkit-learn/blob/master/gklearn/kernels/weisfeiler_lehman.py) [11] + * [Subtree](https://github.com/jajupmochi/graphkit-learn/blob/master/gklearn/kernels/weisfeiler_lehman.py#L479) + +A demo of computing graph kernels can be found on [Google Colab](https://colab.research.google.com/drive/17Q2QCl9CAtDweGF8LiWnWoN2laeJqT0u?usp=sharing) and in the [`examples`](https://github.com/jajupmochi/graphkit-learn/blob/master/gklearn/examples/compute_graph_kernel.py) folder. + +### Graph Edit Distances -## Computation optimization methods +### Graph preimage methods + +A demo of generating graph preimages can be found on [Google Colab](https://colab.research.google.com/drive/1PIDvHOcmiLEQ5Np3bgBDdu0kLOquOMQK?usp=sharing) and in the [`examples`](https://github.com/jajupmochi/graphkit-learn/blob/master/gklearn/examples/median_preimege_generator.py) folder. + +### Interface to `GEDLIB` + +[`GEDLIB`](https://github.com/dbblumenthal/gedlib) is an easily extensible C++ library for (suboptimally) computing the graph edit distance between attributed graphs. [A Python interface](https://github.com/jajupmochi/graphkit-learn/tree/master/gklearn/gedlib) for `GEDLIB` is integrated in this library, based on [`gedlibpy`](https://github.com/Ryurin/gedlibpy) library. + +### Computation optimization methods * Python’s `multiprocessing.Pool` module is applied to perform **parallelization** on the computations of all kernels as well as the model selection. * **The Fast Computation of Shortest Path Kernel (FCSP) method** [8] is implemented in *the random walk kernel*, *the shortest path kernel*, as well as *the structural shortest path kernel* where FCSP is applied on both vertex and edge kernels. @@ -81,6 +127,10 @@ Linlin Jia, Benoit Gaüzère, and Paul Honeine. Graph Kernels Based on Linear Pa A comparison of performances of graph kernels on benchmark datasets can be found [here](https://graphkit-learn.readthedocs.io/en/master/experiments.html). +## How to contribute + +Fork the library and open a pull request! Make your own contribute to the community! + ## References [1] Thomas Gärtner, Peter Flach, and Stefan Wrobel. On graph kernels: Hardness results and efficient alternatives. Learning Theory and Kernel Machines, pages 129–143, 2003.