gklearn.kernels.randomWalkKernel

@author: linlin

@references:

[1] S Vichy N Vishwanathan, Nicol N Schraudolph, Risi Kondor, and Karsten M Borgwardt. Graph kernels. Journal of Machine Learning Research, 11(Apr):1201–1242, 2010.
computeVK(g1, g2, ds_attrs, node_kernels, node_label)[source]

Compute vertex kernels between vertices of two graphs.

computeW(g1, g2, vk_dict, ds_attrs, edge_kernels, edge_label)[source]

Compute weight matrix of the direct product graph.

filterGramMatrix(gmt, label_dict, label, directed)[source]

Compute (the transpose of) the Gram matrix filtered by a label.

func_fp(x, p_times, lmda, w_times)[source]
getLabels(Gn, node_label, edge_label, directed)[source]

Get symbolic labels of a graph dataset, where vertex labels are dealt with by concatenating them to the edge labels of adjacent edges.

randomwalkkernel(*args, compute_method=None, weight=1, p=None, q=None, edge_weight=None, node_kernels=None, edge_kernels=None, node_label='atom', edge_label='bond_type', sub_kernel=None, n_jobs=None, verbose=True)[source]

Calculate random walk graph kernels.

Gn : List of NetworkX graph
List of graphs between which the kernels are calculated.
G1, G2 : NetworkX graphs
Two graphs between which the kernel is calculated.
compute_method : string

Method used to compute kernel. The Following choices are available:

‘sylvester’ - Sylvester equation method.

‘conjugate’ - conjugate gradient method.

‘fp’ - fixed-point iterations.

‘spectral’ - spectral decomposition.

weight : float
A constant weight set for random walks of length h.
p : None
Initial probability distribution on the unlabeled direct product graph of two graphs. It is set to be uniform over all vertices in the direct product graph.
q : None
Stopping probability distribution on the unlabeled direct product graph of two graphs. It is set to be uniform over all vertices in the direct product graph.

edge_weight : float

Edge attribute name corresponding to the edge weight.
node_kernels: dict
A dictionary of kernel functions for nodes, including 3 items: ‘symb’ for symbolic node labels, ‘nsymb’ for non-symbolic node labels, ‘mix’ for both labels. The first 2 functions take two node labels as parameters, and the ‘mix’ function takes 4 parameters, a symbolic and a non-symbolic label for each the two nodes. Each label is in form of 2-D dimension array (n_samples, n_features). Each function returns a number as the kernel value. Ignored when nodes are unlabeled. This argument is designated to conjugate gradient method and fixed-point iterations.
edge_kernels: dict
A dictionary of kernel functions for edges, including 3 items: ‘symb’ for symbolic edge labels, ‘nsymb’ for non-symbolic edge labels, ‘mix’ for both labels. The first 2 functions take two edge labels as parameters, and the ‘mix’ function takes 4 parameters, a symbolic and a non-symbolic label for each the two edges. Each label is in form of 2-D dimension array (n_samples, n_features). Each function returns a number as the kernel value. Ignored when edges are unlabeled. This argument is designated to conjugate gradient method and fixed-point iterations.
node_label: string
Node attribute used as label. The default node label is atom. This argument is designated to conjugate gradient method and fixed-point iterations.
edge_label : string
Edge attribute used as label. The default edge label is bond_type. This argument is designated to conjugate gradient method and fixed-point iterations.
sub_kernel: string
Method used to compute walk kernel. The Following choices are available: ‘exp’ : method based on exponential serials. ‘geo’ : method based on geometric serials.
n_jobs: int
Number of jobs for parallelization.
Kmatrix : Numpy matrix
Kernel matrix, each element of which is the path kernel up to d between 2 praphs.
wrapper_cg_labled_do(ds_attrs, node_kernels, node_label, edge_kernels, edge_label, lmda, itr)[source]
wrapper_cg_unlabled_do(lmda, itr)[source]
wrapper_fp_labled_do(ds_attrs, node_kernels, node_label, edge_kernels, edge_label, lmda, itr)[source]
wrapper_sd_do(weight, sub_kernel, itr)[source]
wrapper_se_do(lmda, itr)[source]