Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting IDs from t-SNE plot?

Tags:

python

mapping

Quite simple, If I perform t-SNE in Python for high-dimensional data then I get 2 or 3 coordinates that reflect each new point. But how do I map these to the original IDs?

One way that I can think of is if the indices are kept fixed the entire time, then I can do:

  1. Pick a point in t-SNE
  2. See what row it was in t-SNE (e.g. index 7)
  3. Go to original data and pick out row/index 7.

However, I don't know how to check if this actually works. My data is super high-dimensional and it is very hard to make sense of it with a normal "sanity check".

Thanks a lot!

Best,

like image 805
Kim O Avatar asked Aug 06 '26 22:08

Kim O


1 Answers

If you are using sklearn's t-SNE, then your assumption is correct. The ordering of the inputs match the ordering of the outputs. So if you do y=TSNE(n_components=n).fit_transform(x) then y and x will be in the same order so y[7] will be the embedding of x[7]. You can trust scikit-learn that this will be the case.

like image 111
enumaris Avatar answered Aug 09 '26 13:08

enumaris