DRModule#

class torchdr.DRModule(n_components: int = 2, device: str = 'auto', backend: str | None = None, verbose: bool = False, random_state: float | None = None)[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.

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

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

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

abstract fit_transform(X: Tensor | ndarray, y: Any | None = 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:#

Neighbor Embedding on genomics & equivalent affinity matcher formulation

Neighbor Embedding on genomics & equivalent affinity matcher formulation

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

TSNE vs COSNE : Euclidean vs Hyperbolic

TSNE vs COSNE : Euclidean vs Hyperbolic