k-NN is kind of an interesting machine learning algorithm because it is extremely simple (just take the average of the closest k data points in your dataset), but is, in a certain sense, the "ideal" algorithm. In the limit that the size of your data goes to infinity, k-NN performs perfectly. With the appropriate choice of k it is impossible for any algorithm, no matter how clever, to outperform it. Other ML algorithm…
I believe it also makes overtraining impossible which is pretty strange for a learning algorithm.
K-Nearest Neighbors
11–20 of 38 posts
Re: K-Nearest Neighbors
#12k-NN is kind of an interesting machine learning algorithm because it is extremely simple (just take the average of the closest k data points in your dataset), but is, in a certain sense, the "ideal" algorithm. In the limit that the size of your data goes to infinity, k-NN performs perfectly. With the appropriate choice of k it is impossible for any algorithm, no matter how clever, to outperform it. Other ML algorithm…
To be more precise, the result is that it is asymptotically no worse than twice as bad as the best classification accuracy possible (the Bayes rate).
KNNs have trivial training cost but, as you pointed out, have a non-trivial cost of generating a prediction.
A related advantage that KNNs have is that it is easy to remove the effect of specific training examples from the model. With GDPR and other future legislations requiring the support of removing not only the user's data, but also the effect of the user's data from a trained model, KNNs are convenient.
Re: K-Nearest Neighbors
#13Re: K-Nearest Neighbors
#14In the past I have used a k-d tree [1] for this, which allows O(log n) searches in the vector space. It seems they are offering a k-d-tree-as-a-service.
Re: K-Nearest Neighbors
#15Re: K-Nearest Neighbors
#16Re: K-Nearest Neighbors
#17Would HN benefit from some kind of "self promotion" or "marketing" tag?
At the least, it's fine ethically as long as it's high effort and there's unique content/approaches, which this is.
Re: K-Nearest Neighbors
#18k-NN is kind of an interesting machine learning algorithm because it is extremely simple (just take the average of the closest k data points in your dataset), but is, in a certain sense, the "ideal" algorithm. In the limit that the size of your data goes to infinity, k-NN performs perfectly. With the appropriate choice of k it is impossible for any algorithm, no matter how clever, to outperform it. Other ML algorithm…
In cryptography, the equivalent is the one-time pad. It has trade-offs which make it unavailable for many uses, but by some measures it is literally perfect and the only thing which can be perfect.
Re: K-Nearest Neighbors
#19I wonder how their advertised "vector database" works. kNN combined with embeddings from pre-trained deep learning models can be very useful for information retrieval, (e.g. searching for duplicate/similar images or text). In the past I have used a k-d tree [1] for this, which allows O(log n) searches in the vector space. It seems they are offering a k-d-tree-as-a-service. [1] https://en.wikipedia.org/wiki/K-d_tree
Indeed! We've been able to build simple reverse image search apps and other solutions using the power of embeddings from pre-trained ML models: https://gist.github.com/fzliu/c9380a7f9ba411adeff0b727cdba15....
One quick note: k-d trees are great for indexing low-dimensional data, but for high-dimensional embeddings they tend to be a poor indexing choice since you'll end up visiting more nodes in the tree than you'd like. I found [1] to be a great overview of different indexing types for high-dimensional vectors and the advantages of each.