Purpose . I want to use t-SNE (t-distributed stochastic neighboring embedding) in R to reduce the dimension of my training data (with N observations and K-variables, where K → N) and in the future we are trying to come up with a t-SNE representation for my test data.
An example . Suppose I want to reduce K variables to D = 2 sizes (often D = 2 or D = 3 for t-SNE). There are two R packages: Rtsneand tsne, while I use it here.
# load packages
library(Rtsne)
# Generate Training Data: random standard normal matrix with J=400 variables and N=100 observations
x.train <- matrix(nrom(n=40000, mean=0, sd=1), nrow=100, ncol=400)
# Generate Test Data: random standard normal vector with N=1 observation for J=400 variables
x.test <- rnorm(n=400, mean=0, sd=1)
# perform t-SNE
set.seed(1)
fit.tsne <- Rtsne(X=x.train, dims=2)
where the command fit.tsne$Ywill return a (100x2) -dimensional object containing the t-SNE data representation; can also be displayed with plot(fit.tsne$Y).
. , pred (1x2) t-SNE. - ,
pred <- predict(object=fit.tsne, newdata=x.test)
() ? ?