Functions in this module operate on existing square matrices, and transform them to acheive normalization, kernels, etc.
Specifically, we plan to provide a set of functions revolving around kernels and proximities defined on the vertices of graphs.
For now, the provided functions are limited to several that are used in the rest of affinis and the associated MENDR benchmark.
For a more complete list of similarities on graphs, see Averachenkov et al. (2019)
proximity
Functions:
-
bilinear_kern–Inverse of the bilinear distance operation to recover a kernel.
-
forest–relative forest accessibilities
-
forest_correlation–Re-scaling of forest matrix to have unit diagonal entries.
-
sinkhorn–Make matrix A doubly-stochastic (rows/cols sum to 1), if possible.
bilinear_kern
Inverse of the bilinear distance operation to recover a kernel.
Parameters:
-
(DSimsMat) –matrix of distances on nodes
forest
relative forest accessibilities
Gauranteed to be PD, stochastic, and strictly positive for connected graphs. For disconnected graphs, a q_ij=0 means no paths exist between nodes i,j.
For each entry of Q,
which is the fraction of spanning forests on the graph of L where i,j are in the same spanning tree, rooted at i.
Also called the Regularized Inverse Laplacian
Source code in affinis/proximity.py
forest_correlation
forest_correlation(L: SimsMat, beta=1.0)
Re-scaling of forest matrix to have unit diagonal entries.
If Q=q_ij gives the fraction of spanning forests where i,j share a spanning tree (rooted at i), then normalizing by the relative forest accessibilities q_ii is analagous to - re-scaling a covariance matrix into correlations, or - rescaling a grammian into a cosine similarity.
Source code in affinis/proximity.py
sinkhorn
Make matrix A doubly-stochastic (rows/cols sum to 1), if possible.
Uses sinkhorn-knop (iterated proportional fitting) to project an n x n matrix A onto the closest point in the Birkhoff polytope.