Skip to content

Error thrown when using t-SNE with 'cosine' as metric #5772

@KaffeLatte

Description

@KaffeLatte

Hi,

When I use 'cosine' as metric for sklearn.manifold.tsne I get the following error:
"ValueError: All distances should be positive, either the metric or precomputed distances given as X are not correct".

As the codomain of cosine distance is [-1,1] all output from pairwise comparison will not be positive.

For euclidean distance there is a hard coded solution for keeping distances positive by squaring them (passed as parameter).

For cosine distance I suspect that a simply 'absoluting' the values should be a fix to make it run, however seems like there should be a proper understanding of the algorithm before doing a fix (which I currently do not have unfortunately)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions