0

I'm trying to use cosine metric with Ball_tree algorithm since my data is of high dimensions. e.g.

nbrs = NearestNeighbors(n_neighbors=2,algorithm='ball_tree',metric='cosine').fit(data_seed)

However i get the following error:

ValueError: Metric 'cosine' not valid. Use sorted(sklearn.neighbors.VALID_METRICS['ball_tree']) to get valid options. Metric can also be a callable function.

I don't understand why i cannot use cosine similarity with ball tree?

Maths12
  • 852
  • 3
  • 17
  • 31

1 Answers1

0

check valid matrics sklearn.neighbors.VALID_METRICS['ball_tree']) and use instead of cosine

user16181
  • 126
  • 4