Skip to main content

FFT-accelerated Interpolation-based t-SNE (FIt-SNE)

Introduction

t-Stochastic Neighborhood Embedding ([t-SNE](https://lvdmaaten.github.io/tsne/)) is a highly successful method for dimensionality reduction and visualization of high dimensional datasets. A popular implementation of t-SNE uses the Barnes-Hut algorithm to approximate the gradient at each iteration of gradient descent. We accelerated this implementation as follows:

  • Computation of the N-body Simulation: Instead of approximating the N-body simulation using Barnes-Hut, we interpolate onto an equispaced grid and use FFT to perform the convolution, dramatically reducing the time to compute the gradient at each iteration of gradient descent. See the this post for some intuition on how it works.

  • Computation of Input Similarities: Instead of computing nearest neighbors using vantage-point trees, we approximate nearest neighbors using the Annoy library. The neighbor lookups are multithreaded to take advantage of machines with multiple cores. Using “near” neighbors as opposed to strictly “nearest” neighbors is faster, but also has a smoothing effect, which can be useful for embedding some datasets (see Linderman et al. (2017)). If subtle detail is required (e.g. in identifying small clusters), then use vantage-point trees (which is also multithreaded in this implementation).

Check out our paper or preprint for more details and some benchmarks.

Features

Additionally, this implementation includes the following features:

  • Early exaggeration: In Linderman and Steinerberger (2018), we showed that appropriately choosing the early exaggeration coefficient can lead to improved embedding of swissrolls and other synthetic datasets. Early exaggeration is built into all t-SNE implementations; here we highlight its importance as a parameter.

  • Late exaggeration: Increasing the exaggeration coefficient late in the optimization process can improve separation of the clusters. Kobak and Berens (2019) suggest starting late exaggeration immediately following early exaggeration.

  • Initialization: Custom initialization can be provided from Python/Matlab/R. As suggested by Kobak and Berens (2019), initializing t-SNE with the first two principal components (scaled to have standard deviation 0.0001) results in an embedding which often preserves the global structure more effectively than the default random normalization. See there for other initialisation tricks.

  • Variable degrees of freedom: Kobak et al. (2019) show that decreasing the degree of freedom (df) of the t-distribution (resulting in heavier tails) reveals fine structure that is not visible in standard t-SNE.

  • All optimisation parameters can be controlled from Python. For example, Belkina et al. (2019) highlight the importance of increasing the learning rate when embedding large data sets.

Implementations

There are (at least) three options for using FIt-SNE in Python:

  • This PyPI package (see installation instructions below), which is a Cython wrapper for FIt-SNE and was written by Gioele La Manno. This package is not directly updated; rather, the C++ code from FIt-SNE is ported here occasionally. The current version of the C++ code corresponds to FIt-SNE 1.1.0 (commit 714e12e).

  • The Python wrapper available from the FIt-SNE Github. It is not on PyPI, but rather wraps the FIt-SNE binary.

  • OpenTSNE, which is a pure Python implementation of FIt-SNE, also available on PyPI.

Installation

The only prerequisite is FFTW. FFTW and fitsne can be installed as follows:

conda config --add channels conda-forge #if not already in your channels. Needed for fftw.
conda install cython numpy fftw
pip install fitsne

And you’re good to go!

Bug reports, feature requests, etc.

If you have any problems with this package, please open an issue on the Github repository.

References

If you use our software, please cite:

George C. Linderman, Manas Rachh, Jeremy G. Hoskins, Stefan Steinerberger, Yuval Kluger. (2019). Fast interpolation-based t-SNE for improved visualization of single-cell RNA-seq data. Nature Methods. (link)

Our implementation is derived from the Barnes-Hut implementation:

Laurens van der Maaten (2014). Accelerating t-SNE using tree-based algorithms. Journal of Machine Learning Research, 15(1):3221–3245. (link)

Metadata

Release files for fitsne 1.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fitsne 1.2.1
File Size Uploaded Provenance Actions
fitsne-1.2.1.tar.gz 158.1 kB Without provenance Details for fitsne-1.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for fitsne 1.2.1
File Interpreter ABI Platform Actions
fitsne-1.2.1-py3.8-linux-x86_64.egg Legacy Egg format - - Details for fitsne-1.2.1-py3.8-linux-x86_64.egg

Total release size: 911.5 kB

Release files / fitsne-1.2.1.tar.gz

Download URL fitsne-1.2.1.tar.gz
Size 158.1 kB
Tags Source
SHA-256 checksum
How to use checksums
3cde3768e453d7dd74f4e17e43dab8d7fa6e9c2e41fb886a87cab3a1a354dc53
BLAKE2b-256 checksum
How to use checksums
0bd46dc0da00310bb9cef100d14ace03418bdef566495390635d6e6355afb6a4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.5.0.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3

Release files / fitsne-1.2.1-py3.8-linux-x86_64.egg

Download URL fitsne-1.2.1-py3.8-linux-x86_64.egg
Size 753.4 kB
Tags Egg
SHA-256 checksum
How to use checksums
df85b8ef638271dbca542da2be9f0047c2d41ab7521be474589fc55119102124
BLAKE2b-256 checksum
How to use checksums
4753409429edb52352fe626135d93e3fed22cf2c050b0f5fb3c43510e377a6bb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.5.0.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3

Security for fitsne 1.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page