# t-distributed stochastic neighbor embedding

T-distributed Stochastic Neighbor Embedding (t-SNE) is a machine learning algorithm for visualization developed by Laurens van der Maaten and Geoffrey Hinton.[1] It is a nonlinear dimensionality reduction technique well-suited for embedding high-dimensional data for visualization in a low-dimensional space of two or three dimensions. Specifically, it models each high-dimensional object by a two- or three-dimensional point in such a way that similar objects are modeled by nearby points and dissimilar objects are modeled by distant points with high probability.

The t-SNE algorithm comprises two main stages. First, t-SNE constructs a probability distribution over pairs of high-dimensional objects in such a way that similar objects have a high probability of being picked while dissimilar points have an extremely small probability of being picked. Second, t-SNE defines a similar probability distribution over the points in the low-dimensional map, and it minimizes the Kullback–Leibler divergence between the two distributions with respect to the locations of the points in the map. Note that while the original algorithm uses the Euclidean distance between objects as the base of its similarity metric, this should be changed as appropriate.

t-SNE has been used for visualization in a wide range of applications, including computer security research,[2] music analysis,[3] cancer research,[4] bioinformatics,[5] and biomedical signal processing.[6] It is often used to visualize high-level representations learned by an artificial neural network.[7]

While t-SNE plots often seem to display clusters, the visual clusters can be influenced strongly by the chosen parameterization and therefore a good understanding of the parameters for t-SNE is necessary. Such "clusters" can be shown to even appear in non-clustered data,[8] and thus may be false findings. Interactive exploration may thus be necessary to choose parameters and validate results.[9][10] It has been demonstrated that t-SNE is often able to recover well-separated clusters, and with special parameter choices, approximates a simple form of spectral clustering.[11]

## Details

Given a set of ${\displaystyle N}$ high-dimensional objects ${\displaystyle \mathbf {x} _{1},\dots ,\mathbf {x} _{N}}$, t-SNE first computes probabilities ${\displaystyle p_{ij}}$ that are proportional to the similarity of objects ${\displaystyle \mathbf {x} _{i}}$ and ${\displaystyle \mathbf {x} _{j}}$, as follows:

${\displaystyle p_{j\mid i}={\frac {\exp(-\lVert \mathbf {x} _{i}-\mathbf {x} _{j}\rVert ^{2}/2\sigma _{i}^{2})}{\sum _{k\neq i}\exp(-\lVert \mathbf {x} _{i}-\mathbf {x} _{k}\rVert ^{2}/2\sigma _{i}^{2})}},}$

As Van der Maaten and Hinton explained: "The similarity of datapoint ${\displaystyle x_{j}}$ to datapoint ${\displaystyle x_{i}}$ is the conditional probability, ${\displaystyle p_{j|i}}$, that ${\displaystyle x_{i}}$ would pick ${\displaystyle x_{j}}$ as its neighbor if neighbors were picked in proportion to their probability density under a Gaussian centered at ${\displaystyle x_{i}}$."[1]

${\displaystyle p_{ij}={\frac {p_{j\mid i}+p_{i\mid j}}{2N}}}$

Moreover, the probabilities with ${\displaystyle i=j}$ are set to zero : ${\displaystyle p_{ii}=0}$

The bandwidth of the Gaussian kernels ${\displaystyle \sigma _{i}}$ is set in such a way that the perplexity of the conditional distribution equals a predefined perplexity using the bisection method. As a result, the bandwidth is adapted to the density of the data: smaller values of ${\displaystyle \sigma _{i}}$ are used in denser parts of the data space.

Since the Gaussian kernel uses the Euclidean distance ${\displaystyle \lVert x_{i}-x_{j}\rVert }$, it is affected by the curse of dimensionality, and in high dimensional data when distances lose the ability to discriminate, the ${\displaystyle p_{ij}}$ become too similar (asymptotically, they would converge to a constant). It has been proposed to adjust the distances with a power transform, based on the intrinsic dimension of each point, to alleviate this.[12]

t-SNE aims to learn a ${\displaystyle d}$-dimensional map ${\displaystyle \mathbf {y} _{1},\dots ,\mathbf {y} _{N}}$ (with ${\displaystyle \mathbf {y} _{i}\in \mathbb {R} ^{d}}$) that reflects the similarities ${\displaystyle p_{ij}}$ as well as possible. To this end, it measures similarities ${\displaystyle q_{ij}}$ between two points in the map ${\displaystyle \mathbf {y} _{i}}$ and ${\displaystyle \mathbf {y} _{j}}$, using a very similar approach. Specifically, ${\displaystyle q_{ij}}$ is defined as:

${\displaystyle q_{ij}={\frac {(1+\lVert \mathbf {y} _{i}-\mathbf {y} _{j}\rVert ^{2})^{-1}}{\sum _{k\neq i}(1+\lVert \mathbf {y} _{i}-\mathbf {y} _{k}\rVert ^{2})^{-1}}}}$

Herein a heavy-tailed Student t-distribution (with one-degree of freedom, which is the same as a Cauchy distribution) is used to measure similarities between low-dimensional points in order to allow dissimilar objects to be modeled far apart in the map. Note that also in this case we set ${\displaystyle q_{ii}=0}$

The locations of the points ${\displaystyle \mathbf {y} _{i}}$ in the map are determined by minimizing the (non-symmetric) Kullback–Leibler divergence of the distribution ${\displaystyle Q}$ from the distribution ${\displaystyle P}$, that is:

${\displaystyle KL(P||Q)=\sum _{i\neq j}p_{ij}\log {\frac {p_{ij}}{q_{ij}}}}$

The minimization of the Kullback–Leibler divergence with respect to the points ${\displaystyle \mathbf {y} _{i}}$ is performed using gradient descent. The result of this optimization is a map that reflects the similarities between the high-dimensional inputs well.

## References

1. ^ a b van der Maaten, L.J.P.; Hinton, G.E. (Nov 2008). "Visualizing Data Using t-SNE" (PDF). Journal of Machine Learning Research. 9: 2579–2605.
2. ^ Gashi, I.; Stankovic, V.; Leita, C.; Thonnard, O. (2009). "An Experimental Study of Diversity with Off-the-shelf AntiVirus Engines". Proceedings of the IEEE International Symposium on Network Computing and Applications: 4–11.
3. ^ Hamel, P.; Eck, D. (2010). "Learning Features from Music Audio with Deep Belief Networks". Proceedings of the International Society for Music Information Retrieval Conference: 339–344.
4. ^ Jamieson, A.R.; Giger, M.L.; Drukker, K.; Lui, H.; Yuan, Y.; Bhooshan, N. (2010). "Exploring Nonlinear Feature Space Dimension Reduction and Data Representation in Breast CADx with Laplacian Eigenmaps and t-SNE". Medical Physics. 37 (1): 339–351. doi:10.1118/1.3267037. PMC 2807447. PMID 20175497.
5. ^ Wallach, I.; Liliean, R. (2009). "The Protein-Small-Molecule Database, A Non-Redundant Structural Resource for the Analysis of Protein-Ligand Binding". Bioinformatics. 25 (5): 615–620. doi:10.1093/bioinformatics/btp035. PMID 19153135.
6. ^ Birjandtalab, J.; Pouyan, M. B.; Nourani, M. (2016-02-01). Nonlinear dimension reduction for EEG-based epileptic seizure detection. 2016 IEEE-EMBS International Conference on Biomedical and Health Informatics (BHI). pp. 595–598. doi:10.1109/BHI.2016.7455968. ISBN 978-1-5090-2455-1.
7. ^ Visualizing Representations: Deep Learning and Human Beings Christopher Olah's blog, 2015
8. ^ "K-means clustering on the output of t-SNE". Cross Validated. Retrieved 2018-04-16.
9. ^ Pezzotti, Nicola; Lelieveldt, Boudewijn P. F.; Maaten, Laurens van der; Hollt, Thomas; Eisemann, Elmar; Vilanova, Anna (2017-07-01). "Approximated and User Steerable tSNE for Progressive Visual Analytics". IEEE Transactions on Visualization and Computer Graphics. 23 (7): 1739–1752. arXiv:1512.01655. doi:10.1109/tvcg.2016.2570755. ISSN 1077-2626. PMID 28113434.
10. ^ Wattenberg, Martin; Viégas, Fernanda; Johnson, Ian (2016-10-13). "How to Use t-SNE Effectively". Distill. Retrieved 4 December 2017.
11. ^ Linderman, George C.; Steinerberger, Stefan (2017-06-08). "Clustering with t-SNE, provably". arXiv:1706.02582 [cs.LG].
12. ^ Schubert, Erich; Gertz, Michael (2017-10-04). Intrinsic t-Stochastic Neighbor Embedding for Visualization and Outlier Detection. SISAP 2017 – 10th International Conference on Similarity Search and Applications. pp. 188–203. doi:10.1007/978-3-319-68474-1_13.