graphdot.metric package¶
-
class
graphdot.metric.
MaxiMin
(*args, **kwargs)[source]¶ Bases:
graphdot.kernel.marginalized._kernel.MarginalizedGraphKernel
The maximin graph distance is a variant of the Hausdorff distance. Given the nodal similarity measure defined on individual nodes by the marginalized graph kernel, the maximin distance is the greatest of all the kernel-induced distances from a node in one graph to the closest node in the other graph. Two graphs are close in the maximin distance if every node of either graph is close to some node of the other graph.
Parameters: - args (arguments) – Inherits from
graphdot.kernel.marginalized.MarginalizedGraphKernel
. - kwargs (keyword arguments) – Inherits from
graphdot.kernel.marginalized.MarginalizedGraphKernel
.
-
__call__
(X, Y=None, eval_gradient=False, lmin=0, return_hotspot=False, timing=False)[source]¶ Computes the distance matrix and optionally its gradient with respect to hyperparameters.
Parameters: - X (list of graphs) – The first dataset to be compared.
- Y (list of graphs or None) – The second dataset to be compared. If None, X will be compared with itself.
- eval_gradient (bool) – If True, returns the gradient of the weight matrix alongside the matrix itself.
- lmin (0 or 1) – Number of steps to skip in each random walk path before similarity is computed. (lmin + 1) corresponds to the starting value of l in the summation of Eq. 1 in Tang & de Jong, 2019 https://doi.org/10.1063/1.5078640 (or the first unnumbered equation in Section 3.3 of Kashima, Tsuda, and Inokuchi, 2003).
- return_hotspot (bool) – Whether or not to return the indices of the node pairs that determines the maximin distance between the graphs. Generally, these hotspots represent the location of the largest difference between the graphs.
- options (keyword arguments) – Additional arguments to be passed to the underlying kernel.
Returns: - distance (2D matrix) – A distance matrix between the data points.
- hotspot (a pair of 2D integer matrices) – Indices of the hotspot node pairs between the graphs. Only
returned if the
return_hotspot
argument is True. - gradient (3D tensor) – A tensor where the i-th frontal slide [:, :, i] contain the partial
derivative of the distance matrix with respect to the i-th
hyperparameter. Only returned if the
eval_gradient
argument is True.
- args (arguments) – Inherits from
-
class
graphdot.metric.
KernelInducedDistance
(kernel, kernel_options={})[source]¶ Bases:
object
The kernel-induced distance is defined by :py:math:`d(x, y) = \sqrt{\frac{1}{2}(k(x, x) + k(y, y)) - k(x, y)}`.
Parameters: - kernel (callable) – A positive semidefinite kernel such as one from
graphdot.kernel
. - kernel_options (dict) – Additional arguments to be forwarded to the kernel.
-
__call__
(X, Y=None, eval_gradient=False)[source]¶ Computes the distance matrix and optionally its gradient with respect to hyperparameters.
Parameters: - X (list of graphs) – The first dataset to be compared.
- Y (list of graphs or None) – The second dataset to be compared. If None, X will be compared with itself.
- eval_gradient (bool) – If True, returns the gradient of the weight matrix alongside the matrix itself.
Returns: - distance (2D matrix) – A distance matrix between the data points.
- gradient (3D tensor) – A tensor where the i-th frontal slide [:, :, i] contain the partial
derivative of the distance matrix with respect to the i-th
hyperparameter. Only returned if the
eval_gradient
argument is True.
-
bounds
¶
-
hyperparameters
¶
-
theta
¶
- kernel (callable) – A positive semidefinite kernel such as one from