gklearn.kernels.weisfeilerLehmanKernel¶
@author: linlin
@references:
[1] Shervashidze N, Schweitzer P, Leeuwen EJ, Mehlhorn K, Borgwardt KM. Weisfeiler-lehman graph kernels. Journal of Machine Learning Research. 2011;12(Sep):2539-61.
-
compute_kernel_matrix
(Kmatrix, all_num_of_each_label, Gn, parallel, n_jobs, verbose)[source]¶ Compute kernel matrix using the base kernel.
-
compute_subtree_kernel
(num_of_each_label1, num_of_each_label2, kernel)[source]¶ Compute the subtree kernel.
-
weisfeilerlehmankernel
(*args, node_label='atom', edge_label='bond_type', height=0, base_kernel='subtree', parallel=None, n_jobs=None, verbose=True)[source]¶ Calculate Weisfeiler-Lehman kernels between graphs.
- 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.
- node_label : string
- Node attribute used as label. The default node label is atom.
- edge_label : string
- Edge attribute used as label. The default edge label is bond_type.
- height : int
- Subtree height.
- base_kernel : string
- Base kernel used in each iteration of WL kernel. Only default ‘subtree’ kernel can be applied for now.
- parallel : None
- Which paralleliztion method is applied to compute the kernel. No parallelization can be applied for now.
- n_jobs : int
- Number of jobs for parallelization. The default is to use all computational cores. This argument is only valid when one of the parallelization method is applied and can be ignored for now.
- Kmatrix : Numpy matrix
- Kernel matrix, each element of which is the Weisfeiler-Lehman kernel between 2 praphs.
This function now supports WL subtree kernel only.