gklearn.utils.kernels

Those who are not graph kernels. We can be kernels for nodes or edges! These kernels are defined between pairs of vectors.

deltakernel(x, y)[source]

Delta kernel. Return 1 if x == y, 0 otherwise.

x, y : any
Two parts to compare.
kernel : integer
Delta kernel.

[1] H. Kashima, K. Tsuda, and A. Inokuchi. Marginalized kernels between labeled graphs. In Proceedings of the 20th International Conference on Machine Learning, Washington, DC, United States, 2003.

gaussiankernel(x, y, gamma=None)[source]

Gaussian kernel. Compute the rbf (gaussian) kernel between x and y:

K(x, y) = exp(-gamma ||x-y||^2).

Read more in the User Guide of scikit-learn library.

x, y : array

gamma : float, default None
If None, defaults to 1.0 / n_features

kernel : float

kernelproduct(k1, k2, d11, d12, d21=None, d22=None, lamda=1)[source]

Product of a pair of kernels.

k = lamda * k1(d11, d12) * k2(d21, d22)

k1, k2 : function
A pair of kernel functions.
d11, d12:
Inputs of k1. If d21 or d22 is None, apply d11, d12 to both k1 and k2.
d21, d22:
Inputs of k2.
lamda: float
Coefficient of the product.

kernel : integer

kernelsum(k1, k2, d11, d12, d21=None, d22=None, lamda1=1, lamda2=1)[source]

Sum of a pair of kernels.

k = lamda1 * k1(d11, d12) + lamda2 * k2(d21, d22)

k1, k2 : function
A pair of kernel functions.
d11, d12:
Inputs of k1. If d21 or d22 is None, apply d11, d12 to both k1 and k2.
d21, d22:
Inputs of k2.
lamda1, lamda2: float
Coefficients of the product.

kernel : integer

linearkernel(x, y)[source]

Polynomial kernel. Compute the polynomial kernel between x and y:

K(x, y) = <x, y>.

x, y : array

d : integer, default 1

c : float, default 0

kernel : float

polynomialkernel(x, y, d=1, c=0)[source]

Polynomial kernel. Compute the polynomial kernel between x and y:

K(x, y) = <x, y> ^d + c.

x, y : array

d : integer, default 1

c : float, default 0

kernel : float