1
$\begingroup$

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?)

$\endgroup$
1
$\begingroup$

That's a particular peculiarity of TSNE in sklearn: https://github.com/scikit-learn/scikit-learn/issues/5361

$\endgroup$
  • $\begingroup$ Huh, what is even the point of tsne then? It onnly shows that my data can be neatly reduced to 2 dimensions? $\endgroup$ – NoLand'sMan Dec 6 '19 at 15:02
  • $\begingroup$ @NoLand'sMan Yes, for now it seems to primarily be a visualization helper. As discussed in the linked issue, there may be a way to use it as a complete transformer, but it has not yet been implemented. $\endgroup$ – Ben Reiniger Dec 6 '19 at 16:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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