Quick Start Tutorial

Marginalized Graph kernel

This quick-start guide here assumes that the reader is already familiar with the marginalized graph kernel algorithm [Kashima, H., Tsuda, K., & Inokuchi, A. (2003). Marginalized kernels between labeled graphs. In Proceedings of the 20th international conference on machine learning (ICML-03) (pp. 321-328).]. Otherwise, please refer to A Short Tutorial on the Marginalized Graph Kernel.

Graphs can be imported from a variety of formats, such as a networkx undirected Graph, an ASE atoms collection, a pymatgen structure or molecule, a SMILES string.

To compare the overall similarity between two graphs, the user needs to supply two base kernels: one for comparing individual nodes, and another one for comparing individual edges. The base kernels can be picked from a library of prebuilt kernels as defined in the graphdot.kernel.basekernel module:

graphdot.kernel.basekernel.Constant(c, c_bounds='fixed')[source]

Creates a no-op microkernel that returns a constant value, i.e. \(k_\mathrm{c}(\cdot, \cdot) \equiv constant\). This kernel is often mutliplied with other microkernels as an adjustable weight.

Parameters:c (float > 0) – The constant value.
graphdot.kernel.basekernel.KroneckerDelta(h, h_bounds=(0.001, 1))[source]

Creates a Kronecker delta microkernel that returns either 1 or h depending on whether two features compare equal, i.e. \(k_\delta(i, j) = \begin{cases} 1, i = j \\ h, otherwise \end{cases}\).

Parameters:
  • h (float in (0, 1)) – The value of the microkernel when two features do not compare equal.
  • h_bounds (tuple or "fixed") – If tuple, contains the lower and upper bounds that h is allowed to vary during hyperparameter optimization. If “fixed”, the hyperparameter will not be optimized during training.
graphdot.kernel.basekernel.SquareExponential(*args, **kwargs)

A square exponential kernel smoothly transitions from 1 to 0 as the distance between two vectors increases from zero to infinity, i.e. \(k_\mathrm{se}(\mathbf{x}, \mathbf{y}) = \exp(-\frac{1}{2} \frac{\lVert \mathbf{x} - \mathbf{y} \rVert^2}{\sigma^2})\)

Parameters:
  • length_scale (float32) – Determines how quickly should the kernel decay to zero. The kernel has a value of approx. 0.606 at one length scale, 0.135 at two length scales, and 0.011 at three length scales.
  • length_scale_bounds (tuple or "fixed") – Lower and upper bounds of length_scale with respect to hyperparameter optimization. If “fixed”, the hyperparameter will not be optimized during training.
graphdot.kernel.basekernel.TensorProduct(**kw_kernels)[source]

Alias of Composite(‘*’, **kw_kernels). \(k_\otimes(X, Y) = \prod_{a \in \mathrm{features}} k_a(X_a, Y_a)\)