4
$\begingroup$

Let's say I begin with an exceptionally large dataframe (e.g. imported/munged from tsv files). Several of these columns are categorical labels.

(As a more concrete example, let's imagine a group of students in a school district, pre-school to high-school).

Now, I begin using sklearn and instantiate a t-SNE model, similar to the example here:

http://scikit-learn.org/stable/modules/generated/sklearn.manifold.TSNE.html

 import numpy as np
 from sklearn.manifold import TSNE
 X  # my data
 model = TSNE(n_components=2, random_state=0)
 np.set_printoptions(suppress=True)
 model.fit_transform(X) 

and then we plot this. The plot might look something like this: https://i.stack.imgur.com/Dgeu8.jpg

Here's my problem: with real datasets, after using t-sne to learn/cluster, you will have a number of "clusters". Then, using the categorical labels, I try to go through each of these, and try to figure out what structure the t-SNE plot is giving me.

For our school example, I'd get the t-SNE output, then I would label the datapoints. (Let's assume that the clusters are actually representative of age/classroom, e.g. the first-graders group together, the second-graders are a group, etc.)

If I try to color this plot with "grades", I'll see that the grades does not really explain the structure of this plot. (Why? Because every class-level has students with As, Bs, Cs, etc.) Then I might try height...that does pretty good (because there's a correlation between short students--> pre-school, tall students --> high school seniors).

How does one use a t-SNE plot to infer the "most correct" labels of the data? How does one use t-SNE plots to explain (and further explore) the plot structure?

$\endgroup$
10
  • 1
    $\begingroup$ The tSNE authors, if I recall correctly, advise against using tSNE for clustering or other analysis. They consider it to be only suited for presentation, because it may pull similar objects too far apart. $\endgroup$ Jan 28, 2017 at 20:00
  • $\begingroup$ @Anony-Mousse What do you mean, "presentation"? $\endgroup$ Jan 29, 2017 at 11:13
  • $\begingroup$ As in "visualization of results". $\endgroup$ Jan 29, 2017 at 12:34
  • $\begingroup$ @Anony-Mousse Just visualizing data? That's a bit odd---the authors directly contrast t-SNE with PCA... $\endgroup$ Jan 29, 2017 at 19:50
  • $\begingroup$ The paper is very clear about the use case (first word is 'visualizing'!) - and it's fairly easy to see that tSNE does not preserve density by design. But density is what makes up clusters (even in methods not considered to be density-based). $\endgroup$ Jan 29, 2017 at 20:26

1 Answer 1

4
$\begingroup$

With t-SNE none of the input parameters are weighted more than any other parameter so the differences you want to see like students forming islands by grade level will not happen because there is so much other data present to pull those students/data points in different directions.

I highly encourage you to have a specific question in mind and tailor your input categories so that your question can be answered by the t-sne map.

You might try asking a specific question and changing which input categories you ask t-SNE to look at. For example, do taller students get better grades? Feed in height and grades categories while leaving out grade level and age. This is a silly example but I hope it gives an idea of how you can use t-sne to help you learn about your data.

You might also find that there are categories that mask meaningful findings. Height might not be very useful for pulling out meaningful information and since the height range is going to be much larger than the A-F grade range, it will likely influence the t-sne map more.

Looking at the data as you described on a color scale for each category is a good place to start with each new t-sne run.

It is okay to run multiple t-snes with different parameters. To be sure you are getting a meaningful answer, I recommend running t-sne multiple times with the same parameters as well.

If you have enough students, it would be great to included half in your training set where you explore and figure out what questions to ask and then when you think you've found something meaningful, apply those conditions to the other students in the testing set to see if it holds true.

$\endgroup$
1
  • $\begingroup$ " For example, do taller students get better grades? Feed in height and grades categories while leaving out grade level and age. This is a silly example but I hope it gives an idea of how you can use t-sne to help you learn about your data." This is a good suggestion. Thank you. It's a good method for seeing the structure of t-SNE. $\endgroup$ Jan 27, 2017 at 20:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.