I have a little problem for doing TSNE in my dataset using cosine similarity.
I calculated the cosine similarity of all my vectors, so I have a square matrix that contains my similarity to cosine:
A = [[ 1 0.7 0.5 0.6 ] [ 0.7 1 0.3 0.4 ] [ 0.5 0.3 1 0.1 ] [ 0.6 0.4 0.1 1 ]]
Then I use TSNE as follows:
A = np.matrix([[1, 0.7,0.5,0.6],[0.7,1,0.3,0.4],[0.5,0.3,1,0.1],[0.6,0.4,0.1,1]]) model = manifold.TSNE(metric="precomputed") Y = model.fit_transform(A)
But I'm not sure what to use a precalculated metric to understand the meaning of my cosine:
But when I try to use the cosine metric, I got an error:
A = np.matrix([[1, 0.7,0.5,0.6],[0.7,1,0.3,0.4],[0.5,0.3,1,0.1],[0.6,0.4,0.1,1]]) model = manifold.TSNE(metric="cosine") Y = model.fit_transform(A) raise ValueError("All distances should be positive, either " ValueError: All distances should be positive, either the metric or precomputed distances given as X are not correct
So my question is: how can TSNE be performed using the cosine metric on an existing dataset (similarity matrix)?