Browse Source

Add graph kernel metadata.

v0.2.x
jajupmochi 4 years ago
parent
commit
ed1cc42997
3 changed files with 48 additions and 1 deletions
  1. +2
    -0
      gklearn/kernels/__init__.py
  2. +36
    -0
      gklearn/kernels/metadata.py
  3. +10
    -1
      gklearn/tests/test_graph_kernels.py

+ 2
- 0
gklearn/kernels/__init__.py View File

@@ -7,6 +7,8 @@ __version__ = "0.1"
__author__ = "Linlin Jia"
__date__ = "November 2018"

from gklearn.kernels.metadata import GRAPH_KERNELS, list_of_graph_kernels

from gklearn.kernels.graph_kernel import GraphKernel
from gklearn.kernels.common_walk import CommonWalk
from gklearn.kernels.marginalized import Marginalized


+ 36
- 0
gklearn/kernels/metadata.py View File

@@ -0,0 +1,36 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Nov 6 10:11:08 2020

@author: ljia
"""

# The metadata of all graph kernels.
GRAPH_KERNELS = {
### based on walks.
'common walk': '',
'marginalized': '',
'sylvester equation': '',
'fixed_point': '',
'conjugate gradient': '',
'spectral decomposition': '',
### based on paths.
'shortest path': '',
'structural shortest path': '',
'path up to length h': '',
### based on non-linear patterns.
'weisfeiler-lehman subtree': '',
'treelet': '',
}


def list_of_graph_kernels():
"""List names of all graph kernels.

Returns
-------
list
The list of all graph kernels.
"""
return [i for i in GRAPH_KERNELS]

+ 10
- 1
gklearn/tests/test_graph_kernels.py View File

@@ -52,6 +52,14 @@ def chooseDataset(ds_name):
return dataset


def test_list_graph_kernels():
"""
"""
from gklearn.kernels import GRAPH_KERNELS, list_of_graph_kernels
assert list_of_graph_kernels() != [i for i in GRAPH_KERNELS]


@pytest.mark.parametrize('ds_name', ['Alkane', 'AIDS'])
@pytest.mark.parametrize('weight,compute_method', [(0.01, 'geo'), (1, 'exp')])
@pytest.mark.parametrize('parallel', ['imap_unordered', None])
@@ -433,9 +441,10 @@ def test_WLSubtree(ds_name, parallel):

if __name__ == "__main__":
test_list_graph_kernels()
# test_spkernel('Alkane', 'imap_unordered')
# test_StructuralSP('Fingerprint_edge', 'imap_unordered')
test_WLSubtree('Acyclic', 'imap_unordered')
# test_WLSubtree('Acyclic', 'imap_unordered')
# test_RandomWalk('Acyclic', 'sylvester', None, 'imap_unordered')
# test_RandomWalk('Acyclic', 'conjugate', None, 'imap_unordered')
# test_RandomWalk('Acyclic', 'fp', None, None)

Loading…
Cancel
Save