eamid / trimap

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

IndexError in running trimap with precomputed values #22

Closed groceryheist closed 2 years ago

groceryheist commented 2 years ago

To reproduce:

import trimap
import numpy as np
import pandas as pd

cossims = pd.read_feather("wiki_rule_cosinesimilarities.feather")

distmat = 1 - np.matrix(cossims.iloc[:,0:cossims.shape[0]],'double')

tmap = trimap.TRIMAP(use_dist_matrix=True)
tmap = tmap.fit_transform(distmat)

I'm attaching the data in a zipfile. wiki_rule_cosinesimilarities.feather.zip

eamid commented 2 years ago

The problem is that you're passing an np.matrix as input. You should pass an np.array instead:

import trimap
import numpy as np
import pandas as pd

cossims = pd.read_feather("wiki_rule_cosinesimilarities.feather")

distmat = 1 - np.matrix(cossims.iloc[:,0:cossims.shape[0]],'double')

# convert to np.array
distmat = np.array(distmat)

tmap = trimap.TRIMAP(use_dist_matrix=True)
tmap = tmap.fit_transform(distmat)
eamid commented 2 years ago

Sorry, I understand that use_dist_matrixis a bit misleading! I'll add a line to convert the input into a numpy array.