As a toy example, I used t-SNE on a simple parabola to have a representation of it in one dimension.
library(tidyverse) library(tsne) theme_set(theme_minimal()) df_parabol <- tibble(x = seq(-5, 5, by = 0.5), y = x^2) N <- nrow(df_parabol) colors <- terrain.colors(N) ggplot(df_parabol) + aes(x, y) + geom_point(color = colors) + geom_text(label = 1:N)
As t-SNE use distances between points to reduce dimensions, I thought I will end up with points on a line with order following the parabola (ie 1 -> 21).
However, points are not ordered at all...
df_tsne <- as.data.frame(tsne(df_parabol, k = 1)) ggplot(df_tsne) + aes(V1, 0) + geom_point(color = colors) + geom_text(label = 1:N)
I also tried several values for perplexity but I got the same results...
df_tsne_cross <- tibble(p = c(2, 4, 10, 30, 50, 90)) %>% mutate(lowdim = map(p, ~ tsne(X = df_parabol, k = 1, perplexity = .)), lowdim = map(lowdim, as.data.frame), lowdim = map(lowdim, mutate, N = 1:N, col = colors)) %>% unnest() ggplot(df_tsne_cross) + aes(V1, 0) + geom_point(aes(color = col)) + geom_text(aes(label = N)) + scale_color_identity(guide = FALSE) + facet_wrap(~ p, scales = "free")
As a comparison, PCA projects the points on the y axis.
Did I need to explore more the space of parameters? Did I expect too much from t-SNE? Do you have an explanation? What is the structure captured by t-SNE here?