tsne
statistics: Y = tsne (X)
statistics: [Y, loss] = tsne (X)
statistics: […] = tsne (…, Name, Value)
t-distributed stochastic neighbor embedding (t-SNE).
Y = tsne (X) embeds the data matrix X
(rows are observations) into a low-dimensional space and returns the
matrix Y of embedded points, whose
pairwise (Student-t) affinities approximate the Gaussian affinities of the
rows of X.
[Y, loss] = tsne (…) also returns the
Kullback-Leibler divergence loss between the two affinity
distributions at the returned embedding.
Name/Value pairs:
'Algorithm''exact' (default) forms the affinities and the gradient over every
pair of points, which costs in time and memory at each
iteration. 'barneshut' approximates both: the high-dimensional
affinities are kept only over each point’s nearest
neighbours, and the repulsive part of the gradient is summed over a
space-partitioning tree of the embedding, giving . Use it
when is large enough that the exact algorithm is slow or cannot
allocate; on this machine the two cost the same at about and
'barneshut' is eight times faster at .
The two do not return the same embedding, and their loss values are
not comparable either: the divergence is summed over the pairs that carry an
affinity, and 'barneshut' keeps far fewer of them.
'Theta''barneshut', a non-negative scalar
(default 0.5). A cell of the tree is collapsed to its centre of mass when
its width is smaller than Theta times its distance from the point
being pushed, so a larger value is faster and coarser. 0 collapses
nothing and makes the repulsion exact, at ; note that this
still leaves the affinities sparse, so it does not reproduce
'exact'. Ignored by 'exact'.'Distance'pdist (default 'euclidean').'NumDimensions'min (P, 2)).'NumPCAComponents''Standardize'false).'Perplexity''Exaggeration''LearnRate''InitialY'1e-4 * randn).'Options'statset) whose MaxIter (default
1000) and TolFun (default 1e-10) fields control the
optimization. The embedding is not unique: it depends on the initial configuration and the
random state. Set 'InitialY' (or the random seed) for a reproducible
result.
Source Code: tsne
Embed a small five-dimensional data set into two dimensions.
X = [randn(20, 5); randn(20, 5) + 5];
Y = tsne (X, "Perplexity", 10);
plot (Y(1:20,1), Y(1:20,2), "bo", Y(21:end,1), Y(21:end,2), "rx");
title ("t-SNE embedding");