0votes
3 answersscikit-learn NearestNeighbors: "Metric 'cosine' not valid for algorithm 'kd_tree'"
I want cosine nearest neighbors with scikit-learn, but specifying algorithm='kdtree' or 'balltree' with metric='cosine' fails.

Find answers to your programming questions.
I want cosine nearest neighbors with scikit-learn, but specifying algorithm='kdtree' or 'balltree' with metric='cosine' fails.
Brute-force search over millions of vectors takes seconds per query. I tried IndexIVFFlat and got an error about istrained.