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.
- gaussian_kernel(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.
Parameters
x, y : array
- gammafloat, default None
If None, defaults to 1.0 / n_features
Returns
kernel : float
- highest_polynomial_kernel(x, y, d=1, c=0)[source]
Polynomial kernel. Compute the polynomial kernel between x and y:
K(x, y) = <x, y> ^d + c.
Parameters
x, y : array
d : integer, default 1
c : float, default 0
Returns
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)
Parameters
- k1, k2function
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.
Return
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)
Parameters
- k1, k2function
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.
Return
kernel : integer
- kronecker_delta_kernel(x, y)[source]
Delta kernel. Return 1 if x == y, 0 otherwise.
Parameters
- x, yany
Two parts to compare.
Return
- kernelinteger
Delta kernel.
References
[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.