pavlin-policar / openTSNE

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

Implement precomputed affinity class #217

Closed dkobak closed 1 year ago

dkobak commented 1 year 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 1 year 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 1 year ago

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

pavlin-policar commented 1 year ago

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