KernelPCA#

class torchdr.KernelPCA(affinity: Affinity = NormalizedGaussianAffinity(), n_components: int = 2, device: str = 'auto', backend: str | FaissConfig | None = None, verbose: bool = False, random_state: float | None = None, nodiag: bool = False, **kwargs)[source]#

Bases: DRModule

Kernel Principal Component Analysis module.

Parameters:
  • affinity (Affinity, default=NormalizedGaussianAffinity(normalization_dim=None)) – Affinity object to compute the kernel matrix.

  • n_components (int, default=2) – Number of components to project the input data onto.

  • device (str, default="auto") – Device on which the computations are performed.

  • backend ({"keops", "faiss", None} or FaissConfig, optional) – Which backend to use for handling sparsity and memory efficiency. Can be: - “keops”: Use KeOps for memory-efficient symbolic computations - “faiss”: Use FAISS for fast k-NN computations with default settings - None: Use standard PyTorch operations - FaissConfig object: Use FAISS with custom configuration Default is None.

  • verbose (bool, default=False) – Whether to print information during the computations.

  • random_state (float, default=None) – Random seed for reproducibility.

  • nodiag (bool, default=False) – Whether to remove eigenvectors with a zero eigenvalue.