# python tsne.transform does not exist?

I am trying to transform two datasets: x_train and x_test using tsne. I assume the way to do this is to fit tsne to x_train, and then transform x_test and x_train. But, I am not able to transform any of the datasets.

tsne = TSNE(random_state = 420, n_components=2, verbose=1, perplexity=5, n_iter=350).fit(x_train)

I assume that tsne has been fitted to x_train.

But, when I do this:

x_train_tse = tsne.transform(x_subset)

I get:

AttributeError: 'TSNE' object has no attribute 'transform'

Any help will be appreciated. (I know I could do fit_transform, but wouldn't I get the same error on x_test?)

The TSNE algorithm doesn't learn a transformation function, it directly optimizes the positions of the lower-dimensional points, therefore the idea of .transform() does not apply to TSNE. One option is to embed a bunch of data via TSNE then use some type of supervised regression (linear regression, for example) to approximate the transformation in order to apply to future data.