Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Map test data using sklearn TSNE

Is there a way to extract the mapping procedure in sklearn.manifold.TSNE in python so that you can map new data into the reduced dimensional space?

Importantly, I mean without having to retrain on the new data as well here.

For example say you trained a TSNE map as follows:

import numpy as np
from sklearn.manifold import TSNE
X = np.array([[0, 0, 0], [0, 1, 1], [1, 0, 1], [1, 1, 1]])
X_embedded = TSNE(n_components=2).fit_transform(X)

As seen in the documentation: https://scikit-learn.org/stable/modules/generated/sklearn.manifold.TSNE.html

Can you extract the transformation so that you can map new data into the same space:

Y = np.array([[0, 0.8, 0.8], [0.1, 0, 1], [1.2, 0.2, 1], [1, 1.1, 1]])

Any help on this matter would be greatly appreciated!

like image 225
user8188120 Avatar asked Aug 06 '26 03:08

user8188120


1 Answers

tSNE is a non-linear, non-parametric embedding.

So there is no "closed form" way of updating it with new points. Even worse: adding new points may require existing points to move.

Because of this, making tSNE apply to new data will require substantial changes to the method, it won't be the original tSNE anymore.

like image 167
Has QUIT--Anony-Mousse Avatar answered Aug 07 '26 17:08

Has QUIT--Anony-Mousse