heat.graph.laplacian
Module for graph-based classes
Module Contents
- 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
- Parameters:
similarity (Callable) – Metric function that defines similarity between vertices. Should accept a data matrix \(n \times f\) as input and return an \(n\times n\) similarity matrix. Additional required parameters can be passed via a lambda function.
definition (str) –
Type of Laplacian
'simple'
: Laplacian matrix for simple graphs \(L = D - A\)'norm_sym'
: Symmetric normalized Laplacian \(L^{sym} = I - D^{-1/2} A D^{-1/2}\)'norm_rw'
: Random walk normalized Laplacian \(L^{rw} = D^{-1} L = I - D^{-1}\)
mode (str) –
How to calculate adjacency from the similarity matrix
'fully_connected'
is fully-connected, so \(A = S\)'eNeighbour'
is the epsilon neighbourhood, with \(A_{ji} = 0\) if \(S_{ij} > upper\) or
\(S_{ij} < lower\); for eNeighbour an upper or lower boundary needs to be set
threshold_key (str) –
'upper'
or'lower'
, defining the type of threshold for the epsilon-neighborhoodthreshold_value (float) – Boundary value for the epsilon-neighborhood
neighbours (int) – Number of nearest neighbors to be considered for adjacency definition. Currently not implemented
- _normalized_symmetric_L(A: heat.core.dndarray.DNDarray) heat.core.dndarray.DNDarray
Helper function to calculate the normalized symmetric Laplacian
\[L^{sym} = D^{-1/2} L D^{-1/2} = I - D^{-1/2} A D^{-1/2}\]- Parameters:
A (DNDarray) – The adjacency matrix of the graph
- _simple_L(A: heat.core.dndarray.DNDarray)
Helper function to calculate the simple graph Laplacian
\[L = D - A\]- Parameters:
A (DNDarray) – The Adjacency Matrix of the graph
- 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- Parameters:
X (DNDarray) – The data matrix, Shape = (n_samples, n_features)