PHATEAffinity#
- class torchdr.PHATEAffinity(metric: str = 'euclidean', device: str | None = None, backend: str | None = None, verbose: bool = False, k: int = 5, alpha: float = 10.0, t: int = 5)[source]#
Bases:
Affinity
Compute the potential affinity used in PHATE [Moon et al., 2019].
The method follows these steps: 1. Compute pairwise distance matrix 2. Find k-th nearest neighbor distances to set bandwidth sigma 3. Compute base affinity with alpha-decay kernel: exp(-((d/sigma)^alpha)) 4. Symmetrize the affinity matrix 5. Row-normalize to create diffusion matrix 6. Raise diffusion matrix to power t (diffusion steps) 7. Compute potential distances from the diffused matrix 8. Return negative potential distances as affinities
- Parameters:
metric (str, optional (default="euclidean")) – Metric to use for pairwise distances computation.
device (str, optional (default=None)) – Device to use for computations. If None, uses the device of input data.
backend ({"keops", "faiss", None}, optional (default=None)) – Which backend to use for handling sparsity and memory efficiency.
verbose (bool, optional (default=False)) – Whether to print verbose output during computation.
k (int, optional (default=5)) – Number of nearest neighbors used to determine bandwidth parameter sigma.
alpha (float, optional (default=10.0)) – Exponent for the alpha-decay kernel in affinity computation.
t (int, optional (default=5)) – Number of diffusion steps (power to raise diffusion matrix).