Session Ready
Exercise

Computing t-SNE

As we have seen, the t-SNE embedding can be computed in R using the Rtsne() function from the Rtsne package in CRAN. Performing a PCA is a common step before running the t-SNE algorithm, but we can skip this step by setting the parameter PCA to FALSE. The dimensionality of the embedding generated by t-SNE can be indicated with the dims parameter.

In this exercise, we will generate a three-dimensional embedding from the mnist_sample dataset without doing the PCA step and then, we will plot the first two dimensions.

The MNIST sample dataset mnist_sample, as well as the Rtsne and ggplot2 packages, are already loaded.

Instructions
100 XP
  • Compute the t-SNE embedding in three dimensions without doing a PCA step for the mnist_sample dataset excluding the label column.
  • Inspect the obtained embedding coordinates which are stored in the Y property of the output object.
  • Create a data frame containing only the first two embedding coordinates as well as the true label of the MNIST digits.
  • Plot these coordinates using ggplot(). Give the points a label and color based on the value of the digit.