pavlin-policar / openTSNE

Extensible, parallel implementations of t-SNE
https://opentsne.rtfd.io
BSD 3-Clause "New" or "Revised" License
1.48k stars 165 forks source link

Implement precomputed affinity class #217

Closed dkobak closed 2 years ago

dkobak commented 2 years ago

Implements #216.

Allows to do the following:

from openTSNE import TSNE
from openTSNE.affinity import PrecomputedAffinities

# Here P is either a np.array or a scipy.sparse matrix
Z = TSNE().fit(affinities = PrecomputedAffinities(P))
pavlin-policar commented 2 years ago

I think this functionality needs a test. Additionally, would it make sense to re-normalize the affinity matrix here? Or do we want to allow un-normalized affinity matrices? Perhaps a normalize parameter defaulting to True might be the way to go. What do you think?

dkobak commented 2 years ago

Good idea about the normalize parameter. Added it, and added a couple of tests as well.

pavlin-policar commented 2 years ago

Wonderful, thanks! I've added a usage-test, which basically just checks that the whole thing works as intended, then I'll merge.