Affinity#

class torchdr.Affinity(metric: str = 'sqeuclidean', zero_diag: bool = True, device: str = 'auto', backend: str | None = None, verbose: bool = False)[source]#

Bases: ABC

Base class for affinity matrices.

Parameters:
  • metric (str, optional) – The distance metric to use for computing pairwise distances.

  • zero_diag (bool, optional) – Whether to set the diagonal of the affinity matrix to zero.

  • device (str, optional) – The device to use for computation. Typically “cuda” for GPU or “cpu” for CPU. If “auto”, uses the device of the input data.

  • backend ({"keops", "faiss", None}, optional) – Which backend to use for handling sparsity and memory efficiency. Default is None.

  • verbose (bool, optional) – Verbosity. Default is False.

Examples using Affinity:#

Entropic Affinities can adapt to varying noise levels

Entropic Affinities can adapt to varying noise levels

PCA via SVD and via AffinityMatcher

PCA via SVD and via AffinityMatcher

Neighbor Embedding on genomics & equivalent affinity matcher formulation

Neighbor Embedding on genomics & equivalent affinity matcher formulation