Skip to content

Commit 068b57a

Browse files
authored
Merge pull request #28 from jajupmochi/v0.2
V0.2
2 parents be4f169 + 7f66196 commit 068b57a

27 files changed

+599
-82
lines changed

.appveyor.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
environment:
22
matrix:
3-
- PYTHON: "C:\\Python35"
4-
- PYTHON: "C:\\Python35-x64"
53
- PYTHON: "C:\\Python36"
64
- PYTHON: "C:\\Python36-x64"
75
- PYTHON: "C:\\Python37"
@@ -17,12 +15,12 @@ environment:
1715

1816
install:
1917
- "%PYTHON%\\python.exe -m pip install -U pip"
20-
- "%PYTHON%\\python.exe -m pip install -U pytest"
21-
- "%PYTHON%\\python.exe -m pip install -r requirements.txt"
2218
- "%PYTHON%\\python.exe -m pip install wheel"
19+
- "%PYTHON%\\python.exe -m pip install -r requirements.txt"
20+
- "%PYTHON%\\python.exe -m pip install -U pytest"
2321

2422
build: off
2523

2624
test_script:
2725
- "%PYTHON%\\python.exe setup.py bdist_wheel"
28-
- "%PYTHON%\\python.exe -m pytest -v gklearn/tests/"
26+
- "%PYTHON%\\python.exe -m pytest -v gklearn/tests/ --ignore=gklearn/tests/test_median_preimage_generator.py"

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
language: python
22

33
python:
4-
- '3.5'
54
- '3.6'
65
- '3.7'
76
- '3.8'

README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ A Python package for graph kernels, graph edit distances and graph pre-image pro
99

1010
## Requirements
1111

12-
* python>=3.5
12+
* python>=3.6
1313
* numpy>=1.16.2
1414
* scipy>=1.1.0
1515
* matplotlib>=3.1.0
@@ -65,27 +65,27 @@ The docs of the library can be found [here](https://graphkit-learn.readthedocs.i
6565
### 1 List of graph kernels
6666

6767
* Based on walks
68-
* [The common walk kernel](gklearn/kernels/common_walk.py) [1]
68+
* [The common walk kernel](https://github.com/jajupmochi/graphkit-learn/tree/master/gklearn/kernels/common_walk.py) [1]
6969
* Exponential
7070
* Geometric
71-
* [The marginalized kenrel](gklearn/kernels/marginalized.py)
71+
* [The marginalized kenrel](https://github.com/jajupmochi/graphkit-learn/tree/master/gklearn/kernels/marginalized.py)
7272
* With tottering [2]
7373
* Without tottering [7]
74-
* [The generalized random walk kernel](gklearn/kernels/random_walk.py) [3]
75-
* [Sylvester equation](gklearn/kernels/sylvester_equation.py)
74+
* [The generalized random walk kernel](https://github.com/jajupmochi/graphkit-learn/tree/master/gklearn/kernels/random_walk.py) [3]
75+
* [Sylvester equation](https://github.com/jajupmochi/graphkit-learn/tree/master/gklearn/kernels/sylvester_equation.py)
7676
* Conjugate gradient
7777
* Fixed-point iterations
78-
* [Spectral decomposition](gklearn/kernels/spectral_decomposition.py)
78+
* [Spectral decomposition](https://github.com/jajupmochi/graphkit-learn/tree/master/gklearn/kernels/spectral_decomposition.py)
7979
* Based on paths
80-
* [The shortest path kernel](gklearn/kernels/shortest_path.py) [4]
81-
* [The structural shortest path kernel](gklearn/kernels/structural_sp.py) [5]
82-
* [The path kernel up to length h](gklearn/kernels/path_up_to_h.py) [6]
80+
* [The shortest path kernel](https://github.com/jajupmochi/graphkit-learn/tree/master/gklearn/kernels/shortest_path.py) [4]
81+
* [The structural shortest path kernel](https://github.com/jajupmochi/graphkit-learn/tree/master/gklearn/kernels/structural_sp.py) [5]
82+
* [The path kernel up to length h](https://github.com/jajupmochi/graphkit-learn/tree/master/gklearn/kernels/path_up_to_h.py) [6]
8383
* The Tanimoto kernel
8484
* The MinMax kernel
8585
* Non-linear kernels
86-
* [The treelet kernel](gklearn/kernels/treelet.py) [10]
87-
* [Weisfeiler-Lehman kernel](gklearn/kernels/weisfeiler_lehman.py) [11]
88-
* [Subtree](gklearn/kernels/weisfeiler_lehman.py#L479)
86+
* [The treelet kernel](https://github.com/jajupmochi/graphkit-learn/tree/master/gklearn/kernels/treelet.py) [10]
87+
* [Weisfeiler-Lehman kernel](https://github.com/jajupmochi/graphkit-learn/tree/master/gklearn/kernels/weisfeiler_lehman.py) [11]
88+
* [Subtree](https://github.com/jajupmochi/graphkit-learn/tree/master/gklearn/kernels/weisfeiler_lehman.py#L479)
8989

9090
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.
9191

@@ -97,7 +97,7 @@ A demo of generating graph preimages can be found on [Google Colab](https://cola
9797

9898
### 4 Interface to `GEDLIB`
9999

100-
[`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](gklearn/gedlib) for `GEDLIB` is integrated in this library, based on [`gedlibpy`](https://github.com/Ryurin/gedlibpy) library.
100+
[`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.
101101

102102
### 5 Computation optimization methods
103103

gklearn/examples/ged/__init__.py

Whitespace-only changes.

gklearn/examples/kernels/__init__.py

Whitespace-only changes.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# -*- coding: utf-8 -*-
2+
"""compute_graph_kernel_v0.1.ipynb
3+
4+
Automatically generated by Colaboratory.
5+
6+
Original file is located at
7+
https://colab.research.google.com/drive/10jUz7-ahPiE_T1qvFrh2NvCVs1e47noj
8+
9+
**This script demonstrates how to compute a graph kernel.**
10+
---
11+
12+
**0. Install `graphkit-learn`.**
13+
"""
14+
15+
"""**1. Get dataset.**"""
16+
17+
from gklearn.utils.graphfiles import loadDataset
18+
19+
graphs, targets = loadDataset('../../../datasets/MUTAG/MUTAG_A.txt')
20+
21+
"""**2. Compute graph kernel.**"""
22+
23+
from gklearn.kernels import untilhpathkernel
24+
25+
gram_matrix, run_time = untilhpathkernel(
26+
graphs, # The list of input graphs.
27+
depth=5, # The longest length of paths.
28+
k_func='MinMax', # Or 'tanimoto'.
29+
compute_method='trie', # Or 'naive'.
30+
n_jobs=1, # The number of jobs to run in parallel.
31+
verbose=True)
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# -*- coding: utf-8 -*-
2+
"""model_selection_old.ipynb
3+
4+
Automatically generated by Colaboratory.
5+
6+
Original file is located at
7+
https://colab.research.google.com/drive/1uVkl7scNgEPrimX8ks6iEC5ijuhB8L_D
8+
9+
**This script demonstrates how to compute a graph kernel.**
10+
---
11+
12+
**0. Install `graphkit-learn`.**
13+
"""
14+
15+
"""**1. Perform model seletion and classification.**"""
16+
17+
from gklearn.utils import model_selection_for_precomputed_kernel
18+
from gklearn.kernels import untilhpathkernel
19+
import numpy as np
20+
21+
# Set parameters.
22+
datafile = '../../../datasets/MUTAG/MUTAG_A.txt'
23+
param_grid_precomputed = {'depth': np.linspace(1, 10, 10),
24+
'k_func': ['MinMax', 'tanimoto'],
25+
'compute_method': ['trie']}
26+
param_grid = {'C': np.logspace(-10, 10, num=41, base=10)}
27+
28+
# Perform model selection and classification.
29+
model_selection_for_precomputed_kernel(
30+
datafile, # The path of dataset file.
31+
untilhpathkernel, # The graph kernel used for estimation.
32+
param_grid_precomputed, # The parameters used to compute gram matrices.
33+
param_grid, # The penelty Parameters used for penelty items.
34+
'classification', # Or 'regression'.
35+
NUM_TRIALS=30, # The number of the random trials of the outer CV loop.
36+
ds_name='MUTAG', # The name of the dataset.
37+
n_jobs=1,
38+
verbose=True)

0 commit comments

Comments
 (0)