Simple-kNN-Gzip icon indicating copy to clipboard operation
Simple-kNN-Gzip copied to clipboard

Metric should be 'precomputed'

Open dilwong opened this issue 2 years ago • 0 comments

Enjoyed your YouTube video on the topic, as well as the comments section discussion on information theory.

My Kernel crashes on Input 14 in kNN-gzip-ncd-video-test it-deep-learning.ipynb for some reason. This is fixed for me by changing Input 13

neigh = KNeighborsClassifier(n_neighbors=7)
neigh.fit(train_ncd, train_y)

to

neigh = KNeighborsClassifier(n_neighbors=7, metric='precomputed')
neigh.fit(train_ncd, train_y)

Unless I'm mistaken in my understanding here, you should be specifying the metric as 'precomputed', right? According to the scikit-learn docs, sklearn.neighbors.KNeighborsClassifier defaults to using the Euclidean metric, which is not what you want.

dilwong avatar Aug 12 '23 23:08 dilwong