DRModule

class torchdr.DRModule(n_components: int = 2, device: str = 'auto', keops: bool = False, verbose: bool = False, random_state: float = 0)[source]

Bases: BaseEstimator, ABC

Base class for DR methods.

Each children class should implement the fit_transform method.

Parameters:
  • 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.

  • keops (bool, default=False) – Whether to use KeOps for computations.

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

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

abstract fit_transform(X: Tensor | ndarray, y=None)[source]

Fit the dimensionality reduction model and transform the input data.

Parameters:
  • X (torch.Tensor or np.ndarray of shape (n_samples, n_features)) – or (n_samples, n_samples) if precomputed is True Input data or input affinity matrix if it is precomputed.

  • y (None) – Ignored.

Raises:

NotImplementedError – This method should be overridden by subclasses.

Examples using DRModule:

PCA via SVD and via AffinityMatcher

PCA via SVD and via AffinityMatcher

TSNE embedding of the swiss roll dataset

TSNE embedding of the swiss roll dataset

Neighbor Embedding on genomics & equivalent affinity matcher formulation

Neighbor Embedding on genomics & equivalent affinity matcher formulation