pyRATS is a lightweight Python tool implementing Riemannian Alignment of Tangent Spaces (RATS) for non-linear dimensionality reduction. With the ubiquity of high-dimensional datasets in various natural sciences, identifying low-dimensional topological manifolds within such datasets may reveal principles connecting latent variables to measurable instances in the world. While leading dimensionality reduction methods introduce distortion during this process, RATS excels at the visualization and deciphering of latent variables. RATS recovers low-distortion embeddings of data, including the ability to embed closed manifolds into their intrinsic dimension using a tearing process.
pip install git+https://github.com/Mishne-Lab/pyRATS
RATS applies three main algorithmic steps:
- It maps locally linear patches of points via (Kernel-)PCA to the embedding space. Postprocessing may be applied on noisy data to remove patches that incur abnormally high distortion.
- It clusters points that apply similar transformations to project to the embedding space.
- It aligns the clusters into a single cluster via rigid alignment.
This bottum-up approach of tearing the manifold apart into smaller clusters allows for leaving the manifold torn.
Closed manifolds can be projected to low dimensional spaces without incurring high distortion only by ripping/ tearing the manifold apart. RATS can provide 'gluing' instructions that indicate which two points on the manifold should be glued back together. Not only are we able to generate accurate low-dimensional embeddings, this feature allows for manifold denoising by projecting it to lower dimensional spaces and projecting back.
A full working example is available here on Google Colab.
You can achieve an equivalent output by installing pyRATS, navigating to the pyRATS/examples folder and running:
from pyRATS import rats
import datasets, vis
# sample 5000 datapoints from a kleinbottle manifold in living in 4d space
X, labels, _ = datasets.Datasets().kleinbottle4d(n=5000)
# create a RATS object projecting the data to 2d while tearing the manifold
model = rats.RATS(d=2, k=28, eta_min=5, to_tear=True)
y = model.fit_transform(X)
# compute the gluing instructions along the tear
tear_color_eig_inds = [7, 2, 4]
color_of_pts_on_tear = model.compute_color_of_pts_on_tear(y, tear_color_eig_inds)
# plot the resulting 2d representation of the manifold
vis.Visualize().global_embedding(
y, labels[:,0],
color_of_pts_on_tear=color_of_pts_on_tear[:,tear_color_eig_inds],
cmap0='coolwarm',
figsize=(3, 3)
)The documentation can be generated with the following commands:
pip install sphinx sphinxcontrib-napoleon
cd docs
make html
cd build/html
python -m http.server 8000and opening http://localhost:8000 in your browser.
@article{rats,
title={RATS: Unsupervised manifold learning using low-distortion alignment of tangent spaces},
author={Kohli, Dhruv and Nieuwenhuis, Johannes S and Cloninger, Alexander and Mishne, Gal and Narain, Devika},
journal={bioRxiv},
pages={2024--10},
year={2024},
publisher={Cold Spring Harbor Laboratory}
}
