0

I am trying to use

KNeighborsClassifier(n_neighbors=15, algorithm='ball_tree', metric='correlation')

However, I get the error

ValueError: Metric 'correlation' not valid for algorithm 'ball_tree'

Why is it not possible to use ball_tree? Am I limited to using brute? I have a huge matrix and would like to avoid brute. But, I can't pass in a custom metric that computes the pearson correlation between two vectors because the triangle inequality is not preserved. Any alternatives to this?

I am on scikit-learn==0.18.1

Mike El Jackson
  • 771
  • 3
  • 14
  • 23

1 Answers1

0

Check out the following documentation:

Ball Tree Documentation

The default distance metric is minkowski for ball_tree. Correlation isn't a valid distance metric to use for that algorithm.

Eric Miller
  • 1,367
  • 4
  • 13
  • 20