eamid / trimap

TriMap: Large-scale Dimensionality Reduction Using Triplets
Apache License 2.0
304 stars 20 forks source link

Distance matrix as input #6

Closed Vykintasj closed 4 years ago

Vykintasj commented 4 years ago

Hi, is it possible to use a precomputed distance matrix as input? / will it be added in the future? Thank you for the reply.

Best regards, Vykintas

eamid commented 4 years ago

Hi Vykintas,

Excellent idea! I will add this feature soon :)

Thank you, Ehsan

eamid commented 4 years ago

Hi Vykintas,

You can now use a precomputed distance matrix as input. To find the embedding using the pairwise distance matrix D, pass D as input and set use_dist_matrix to True:

embedding = trimap.TRIMAP(use_dist_matrix=True).fit_transform(D)

You can also pass the precomputed k-nearest neighbors and their corresponding distances as a tuple (knn_nbrs, knn_distances). Note that in this case, the rows must be in order, starting from point 0 to n-1. This feature also requires X to compute the embedding

embedding = trimap.TRIMAP(knn_tuple=(knn_nbrs, knn_distances)).fit_transform(X)

Please let me know if you find any bugs / errors. Also let me know if you have any comments. Your feedback is highly appreciated.

Ehsan

Vykintasj commented 4 years ago

Hi Ehsan,

I tried only the distance matrix - it works just as intended. Thank you for the implementation! Vykintas