yzhao062/pyod

knn metric cosine ValueError: Unrecognized metric 'cosine'

Open

#221 opened on Aug 19, 2020

View on GitHub
 (3 comments) (0 reactions) (1 assignee)Python (7,762 stars) (1,308 forks)batch import
bughelp wanted

Description

clf = KNN(metric="cosine")
clf.fit(train_data)

results in

sklearn/neighbors/_binary_tree.pxi in sklearn.neighbors._ball_tree.BinaryTree.__init__()

sklearn/neighbors/_dist_metrics.pyx in sklearn.neighbors._dist_metrics.DistanceMetric.get_metric()

ValueError: Unrecognized metric 'cosine'

Also brute and kd_tree don't support cosine, meaning that cosine is not supported by any algorithm.

Contributor guide