Skip to content

Graph Kernels

Graph Kernels are learnable functions that map the graph structure into a lower dimensional representation and are commonly used to solve different problems in graph classification, or regression. In photonai-graph we utilize the grakel graph kernel package. We provide an adapter function that transforms connectivity matrices or networkx graphs into grakel conform graph objects.


A transformer class for transforming graphs into Grakel format.


Name Type Description Default
input_type str

the type of the input, dense or networkx

node_labels dict

a list of the node labels, needed for shortest path kernel

edge_labels dict

list of edge labels if graphs are constructed from networkx graphs

node_feature_construction str

mode of feature construction for graphs constructed from adjacency matrices. "mean" takes the mean of the nodes edge weights, "sum" takes the sum of the nodes edge weights, "degree" takes the node degree, and "features" takes the nodes features as supplied in the feature matrix.

adjacency_axis int

position of the adjacency matrix, default being zero

feature_axis int

position of the feature axis, default being 1



adapter = GrakelAdapter(input_type="dense", node_feature_construction="features")

Grakel Kernels

The available graph kernels include all currently available grakel graph kernels (see Please make sure that you choose the right graph structure meaning that you supply node and edge labels or attributes are required by the specific kernel you are using. A guide on the recommended labels and features can be found in the link above.

For node labels set node_feature_construction to "mean", "sum" or "degree", for node attributes set it to "features".