API and Modules#
Dimensionality Reduction sklearn
Compatible Estimators#
TorchDR provides a set of classes that are compatible with the sklearn
API.
For example, running TSNE
can be done in the exact same way as running
sklearn.manifold.TSNE
with the same parameters.
Note that the TorchDR classes work seamlessly with both Numpy and PyTorch tensors.
For all methods, TorchDR provides the ability to use GPU acceleration using
device='cuda'
as well as LazyTensor objects that allows to fit large scale models
directly on the GPU memory without overflows using keops=True
.
TorchDR supports a variety of dimensionality reduction methods. They are presented in the following sections.
Spectral Embedding#
|
Principal Component Analysis module. |
|
Incremental Principal Components Analysis (IPCA) leveraging PyTorch for GPU acceleration. |
|
Kernel Principal Component Analysis module. |
|
Implementation of PHATE introduced in [Moon et al., 2019]. |
Neighbor Embedding#
|
UMAP introduced in [McInnes et al., 2018] and further studied in [Damrich and Hamprecht, 2021]. |
|
LargeVis algorithm introduced in [Tang et al., 2016]. |
|
PACMAP algorithm introduced in [Wang et al., 2021]. |
|
InfoTSNE algorithm introduced in [Damrich et al., 2022]. |
|
Stochastic Neighbor Embedding (SNE) introduced in [Hinton and Roweis, 2002]. |
|
t-Stochastic Neighbor Embedding (t-SNE) introduced in [Van der Maaten and Hinton, 2008]. |
|
TSNEkhorn algorithm introduced in [Van Assel et al., 2024]. |
|
Implementation of the CO-Stochastic Neighbor Embedding (CO-SNE) introduced in [Guo et al., 2022]. |
Advanced Dimensionality Reduction with TorchDR#
TorchDR provides a set of generic classes that can be used to implement new dimensionality reduction methods. These classes provide a modular and extensible framework that allows you to focus on the core components of your method.
Base Classes#
The torchdr.DRModule
class is the base class for a dimensionality
reduction estimator. It is the base class for all the DR classes in TorchDR.
torchdr.AffinityMatcher
is the base class for all the DR methods that
use gradient-based optimization to minimize a loss function constructed from
two affinities in input and embedding spaces.
|
Base class for DR methods. |
|
Perform dimensionality reduction by matching two affinity matrices. |
Base Neighbor Embedding Modules#
Neighbor embedding base modules inherit from the torchdr.AffinityMatcher
class.
torchdr.SparseNeighborEmbedding
relies on the sparsity of the
input affinity to compute the attractive term in linear time.
torchdr.SampledNeighborEmbedding
inherits from this class and adds the possibility to
approximate the repulsive term of the loss via negative samples.
|
Solves the neighbor embedding problem. |
|
Solves the neighbor embedding problem with a sparse input affinity matrix. |
|
Solves the neighbor embedding problem with both sparsity and sampling. |
Affinity Classes#
Simple Affinities#
|
Compute the Gaussian affinity matrix. |
|
Compute the Student affinity matrix based on the Student-t distribution. |
|
Compute the scalar product affinity matrix. |
|
Compute the Gaussian affinity matrix which can be normalized along a dimension. |
|
Compute the Student affinity matrix which can be normalized along a dimension. |
Affinities Normalized by kNN Distances#
|
Self-tuning affinity introduced in [Zelnik-Manor and Perona, 2004]. |
|
Compute the MAGIC affinity with alpha-decay kernel introduced in [Van Dijk et al., 2018]. |
|
Compute the potential affinity used in PHATE [Moon et al., 2019]. |
|
Compute the input affinity used in PACMAP [Wang et al., 2021]. |
|
Compute the input affinity used in UMAP [McInnes et al., 2018]. |
Entropic Affinities#
|
Compute the symmetric doubly stochastic affinity matrix. |
|
Solve the directed entropic affinity problem introduced in [Hinton and Roweis, 2002]. |
|
Compute the symmetric entropic affinity (SEA) introduced in [Van Assel et al., 2024]. |
Other Affinities#
|
Compute the symmetric doubly stochastic affinity. |
|
Compute the affinity used in embedding space in UMAP [McInnes et al., 2018]. |
Scores#
|
Compute the Silhouette score as the mean of silhouette coefficients. |
Utils#
|
Compute pairwise distances matrix between points in two datasets. |
|
Implement the binary search root finding method. |
|
Implement the false position root finding method. |