Lably
Skip to content

T-distributed stochastic neighbor embedding

Technique for dimensionality reduction

  • 4 min read
  • 3 chapters

Related on Lably

Through Statistics, Probability distribution and Euclidean distance

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 are assigned a higher probability while dissimilar points are assigned a lower probability. Second, t-SNE defines a similar probability distribution over the points in the low-dimensional map, and it minimizes the Kullback–Leibler divergence (KL divergence) between the two distributions with respect to the locations of the points in the map. While the original algorithm uses the Euclidean distance between objects as the base of its similarity metric, this can be changed as appropriate. A Riemannian variant is UMAP.

t-SNE has been used for visualization in a wide range of applications, including genomics, computer security research, natural language processing, music analysis, cancer research, bioinformatics, geological domain interpretation, and biomedical signal processing.

For a data set with n elements, t-SNE runs in O(n2) time and requires O(n2) space.

Details

Given a set of N high-dimensional objects x1,…,xN, t-SNE first computes probabilities pij that are proportional to the similarity of objects xi and xj, as follows.

For i≠j, define

pj∣i=exp⁡(−‖xi−xj‖2/2σi2)∑k≠iexp⁡(−‖xi−xk‖2/2σi2)

and set pi∣i=0. Note the above denominator ensures ∑jpj∣i=1 for all i.

As van der Maaten and Hinton explained: "The similarity of datapoint xj to datapoint xi is the conditional probability, pj|i, that xi would pick xj as its neighbor if neighbors were picked in proportion to their probability density under a Gaussian centered at xi."

Now define

pij=pj∣i+pi∣j2N

This is motivated because pi and pj from the N samples are estimated as 1/N, so the conditional probability can be written as pi∣j=Npij and pj∣i=Npji . Since pij=pji, you can obtain previous formula.

Also note that pii=0 and ∑i,jpij=1.

The bandwidth of the Gaussian kernels σi is set in such a way that the entropy of the conditional distribution equals a predefined entropy using the bisection method. As a result, the bandwidth is adapted to the density of the data: smaller values of σi are used in denser parts of the data space. The entropy increases with the perplexity of this distribution Pi; this relation is seen as

Perp(Pi)=2H(Pi)

where H(Pi) is the Shannon entropy H(Pi)=−∑jpj|ilog2⁡pj|i.

The perplexity is a hand-chosen parameter of t-SNE, and as the authors state, "perplexity can be interpreted as a smooth measure of the effective number of neighbors. The performance of SNE is fairly robust to changes in the perplexity, and typical values are between 5 and 50.".

Since the Gaussian kernel uses the Euclidean distance ‖xi−xj‖, it is affected by the curse of dimensionality, and in high dimensional data when distances lose the ability to discriminate, the pij 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.

t-SNE aims to learn a d-dimensional map y1,…,yN (with yi∈Rd and d typically chosen as 2 or 3) that reflects the similarities pij as well as possible. To this end, it measures similarities qij between two points in the map yi and yj, using a very similar approach. Specifically, for i≠j, define qij as

qij=(1+‖yi−yj‖2)−1∑k∑l≠k(1+‖yk−yl‖2)−1

and set qii=0. 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.

The locations of the points yi in the map are determined by minimizing the (non-symmetric) Kullback–Leibler divergence of the distribution P from the distribution Q, that is:

KL(P∥Q)=∑i≠jpijlog⁡pijqij

The minimization of the Kullback–Leibler divergence with respect to the points yi is performed using gradient descent. The result of this optimization is a map that reflects the similarities between the high-dimensional inputs.

Sign in to keep reading

2 more chapters are free with a Lably account.

More in Computing and communication