Quantum Algorithm for K-Nearest Neighbors Classification Based on the Metric of Hamming Distance

Yue Ruan,Xiling Xue,Heng Liu,Jianing Tan,Xi Li
DOI: https://doi.org/10.1007/s10773-017-3514-4
2017-01-01
International Journal of Theoretical Physics
Abstract:K-nearest neighbors (KNN) algorithm is a common algorithm used for classification, and also a sub-routine in various complicated machine learning tasks. In this paper, we presented a quantum algorithm (QKNN) for implementing this algorithm based on the metric of Hamming distance. We put forward a quantum circuit for computing Hamming distance between testing sample and each feature vector in the training set. Taking advantage of this method, we realized a good analog for classical KNN algorithm by setting a distance threshold value t to select k − n e a r e s t neighbors. As a result, QKNN achieves O(n 3) performance which is only relevant to the dimension of feature vectors and high classification accuracy, outperforms Llyod’s algorithm (Lloyd et al. 2013) and Wiebe’s algorithm (Wiebe et al. 2014).
What problem does this paper attempt to address?