gklearn.kernels.untilHPathKernel

@author: linlin

@references:

[1] Liva Ralaivola, Sanjay J Swamidass, Hiroto Saigo, and Pierre Baldi. Graph kernels for chemical informatics. Neural networks, 18(8):1093–1110, 2005.

find_all_path_as_trie(G, length, ds_attrs, node_label='atom', edge_label='bond_type')[source]
find_all_paths_until_length(G, length, ds_attrs, node_label='atom', edge_label='bond_type', tolabelseqs=True)[source]

Find all paths no longer than a certain maximum length in a graph. A recursive depth first search is applied.

Parameters

GNetworkX graphs

The graph in which paths are searched.

lengthinteger

The maximum length of paths.

ds_attrs: dict

Dataset attributes.

node_labelstring

Node attribute used as label. The default node label is atom.

edge_labelstring

Edge attribute used as label. The default edge label is bond_type.

Return

pathlist

List of paths retrieved, where for unlabeled graphs, each path is represented by a list of nodes; while for labeled graphs, each path is represented by a list of strings consists of labels of nodes and/or edges on that path.

paths2labelseqs(plist, G, ds_attrs, node_label, edge_label)[source]
untilhpathkernel(*args, node_label='atom', edge_label='bond_type', depth=10, k_func='MinMax', compute_method='trie', parallel='imap_unordered', n_jobs=None, chunksize=None, verbose=True)[source]

Compute path graph kernels up to depth/hight h between graphs.

Parameters

GnList of NetworkX graph

List of graphs between which the kernels are computed.

G1, G2NetworkX graphs

Two graphs between which the kernel is computed.

node_labelstring

Node attribute used as label. The default node label is atom.

edge_labelstring

Edge attribute used as label. The default edge label is bond_type.

depthinteger

Depth of search. Longest length of paths.

k_funcfunction

A kernel function applied using different notions of fingerprint similarity, defining the type of feature map and normalization method applied for the graph kernel. The Following choices are available:

‘MinMax’: use the MiniMax kernel and counting feature map.

‘tanimoto’: use the Tanimoto kernel and binary feature map.

None: no sub-kernel is used, the kernel is computed directly.

compute_methodstring

Computation method to store paths and compute the graph kernel. The Following choices are available:

‘trie’: store paths as tries.

‘naive’: store paths to lists.

n_jobsint

Number of jobs for parallelization.

Return

KmatrixNumpy matrix

Kernel matrix, each element of which is the path kernel up to h between 2 praphs.

wrapper_find_all_path_as_trie(length, ds_attrs, node_label, edge_label, itr_item)[source]
wrapper_find_all_paths_until_length(length, ds_attrs, node_label, edge_label, tolabelseqs, itr_item)[source]
wrapper_uhpath_do_kernelless(k_func, itr)[source]
wrapper_uhpath_do_naive(k_func, itr)[source]
wrapper_uhpath_do_trie(k_func, itr)[source]