:mod:`heat.graph.laplacian` =========================== .. py:module:: heat.graph.laplacian .. autoapi-nested-parse:: Module for graph-based classes Module Contents --------------- .. py:class:: Laplacian(similarity: Callable, weighted: bool = True, definition: str = 'norm_sym', mode: str = 'fully_connected', threshold_key: str = 'upper', threshold_value: float = 1.0, neighbours: int = 10) Graph Laplacian from a dataset :param similarity: Metric function that defines similarity between vertices. Should accept a data matrix :math:`n \times f` as input and return an :math:`n\times n` similarity matrix. Additional required parameters can be passed via a lambda function. :type similarity: Callable :param definition: Type of Laplacian - ``'simple'``: Laplacian matrix for simple graphs :math:`L = D - A` - ``'norm_sym'``: Symmetric normalized Laplacian :math:`L^{sym} = I - D^{-1/2} A D^{-1/2}` - ``'norm_rw'``: Random walk normalized Laplacian :math:`L^{rw} = D^{-1} L = I - D^{-1}` :type definition: str :param mode: How to calculate adjacency from the similarity matrix - ``'fully_connected'`` is fully-connected, so :math:`A = S` - ``'eNeighbour'`` is the epsilon neighbourhood, with :math:`A_{ji} = 0` if :math:`S_{ij} > upper` or :math:`S_{ij} < lower`; for eNeighbour an upper or lower boundary needs to be set :type mode: str :param threshold_key: ``'upper'`` or ``'lower'``, defining the type of threshold for the epsilon-neighborhood :type threshold_key: str :param threshold_value: Boundary value for the epsilon-neighborhood :type threshold_value: float :param neighbours: Number of nearest neighbors to be considered for adjacency definition. Currently not implemented :type neighbours: int .. attribute:: similarity_metric .. attribute:: weighted :annotation: = True .. attribute:: neighbours :annotation: = 10 .. role:: raw-html(raw) :format: html .. method:: _normalized_symmetric_L(A: heat.core.dndarray.DNDarray) -> heat.core.dndarray.DNDarray Helper function to calculate the normalized symmetric Laplacian .. math:: L^{sym} = D^{-1/2} L D^{-1/2} = I - D^{-1/2} A D^{-1/2} :param A: The adjacency matrix of the graph :type A: DNDarray .. method:: _simple_L(A: heat.core.dndarray.DNDarray) Helper function to calculate the simple graph Laplacian .. math:: L = D - A :param A: The Adjacency Matrix of the graph :type A: DNDarray .. method:: construct(X: heat.core.dndarray.DNDarray) -> heat.core.dndarray.DNDarray Callable to get the Laplacian matrix from the dataset ``X`` according to the specified Laplacian :param X: The data matrix, Shape = (n_samples, n_features) :type X: DNDarray