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).
Similar content being viewed by others
References
Armbrust, M., Fox, A., Griffith, R., et al.: A view of cloud computing. Commun. ACM. 53(4), 50–58 (2010)
Schölkopf, B., Platt, J., Hofmann, T.: Map-Reduce for machine learning on multicore. In: Proceedings of the 2006 Conference Advances in Neural Information Processing Systems 19, pp. 281–288. MIT Press (2007)
Low, Y., Bickson, D., Gonzalez, J., et al.: Distributed GraphLab: a framework for machine learning and data mining in the cloud. Proceedings of the VLDB Endowment 5(8), 716–727 (2012)
Liu, Q., Cai, W., Shen, J., et al.: A speculative approach to spatial-temporal efficiency with multi-objective optimization in a heterogeneous cloud environment. Security Commun. Netw. 9(17), 4002–4012 (2016)
Xia, Z., Wang, X., Zhang, L., et al.: A privacy-preserving and copy-deterrence content-based image retrieval scheme in cloud computing. IEEE Trans. Inf. Forensics Secur. 11(11), 2594–2608 (2016)
Fu, Z., Ren, K., Shu, J., et al.: Enabling personalized search over encrypted outsourced data with efficiency improvement. IEEE Trans. Parallel Distrib. Syst. 27 (9), 2546–2559 (2016)
Fu, Z., Sun, X., Liu, Q., et al.: Achieving efficient cloud search services: multi-keyword ranked search over encrypted cloud data supporting parallel computing. IEICE Trans. Commun. E98-B(1), 190–200 (2015)
Xia, Z., Wang, X., Sun, X., et al.: A secure and dynamic multi-keyword ranked search scheme over encrypted cloud data. IEEE Trans. Parallel Distrib. Syst. 27(2), 340–352 (2015)
Nielsen, M.A., Chuang, I.L.: Quantum computation and quantum information [M]. Cambridge University Press, Cambridge (2000)
Lloyd, S., Mohseni, M., Rebentrost, P.: Quantum principal component analysis. Nature Physics. 10(9), 631–633 (2014)
Lloyd, S., Mohseni, M., Rebentrost, P.: Quantum algorithms for supervised and unsupervised machine learning. arXiv:1307.0411 (2013)
Lloyd, S., Garnerone, S., Zanardi, P.: Quantum algorithms for topological and geometric analysis of data. Nat. Commun. 7, 10138 (2016)
Wiebe, N., Kapoor, A., Svore, K.: Quantum nearestneighbor algorithms for machine learning. arXiv:1401.2142 (2014)
Wiebe, N., Granade, C., Ferrie, C., et al.: Quantum Hamiltonian learning using imperfect quantum resources. Phys. Rev. A 89(4), 042314 (2014)
Trugenberger, D.A.: Quantum pattern recognition. Quantum Inf. Process. 1(6), 471–493 (2002)
Aïmeur, E., Brassard, G., Gambs, S.: Machine learning in a quantum world. In: Advances in Artificial Intelligence Lecture Notes in Computer Science, vol. 4013, pp 431–442 (2006)
Hentschel, A., Sanders, B.C.: Machine learning for precise quantum measurement. Phys. Rev. Lett. 104(6), 063603 (2010)
Gammelmark, S., Mølmer, K.: Quantum learning by measurement and feedback. New J. Phys. 11, 033017 (2009)
Bisio, A., Chiribella, G., D’Ariano, G.M., et al.: Optimal quantum learning of a unitary transformation. Phys. Rev. A 81(3), 032324 (2010)
Lu, S., Braunstein, S.L.: Quantum decision tree classifier. Quantum Inf. Process. 13(3), 757–770 (2014)
Rebentrost, P., Mohseni, M., Lloyd, S.: Quantum support vector machine for big data classification. Phys. Rev. Lett. 113(13), 130503 (2014)
Schuld, M., Sinayskiy, I., Petruccione, F.: Quantum computing for pattern classification. In: Proceedings 13th Pacific Rim International Conference on Artificial Intelligence (PRICAI), pp 208–220 (2014)
Buhrman, H., Cleve, R., Watrous, J., et al.: Quantum fingerprinting. Phys. Rev. Lett. 87(16), 167902 (2001)
Brassard, G., Høyer, P., Mosca, M., et al.: Quantum amplitude amplification and estimation. arXiv:0005055 [quant-ph/] (2000)
Dürr C., Høyer, P.: A quantum algorithm for finding the minimum. arXiv:9607014 [quant-ph/] (1996)
Manevitz, L.M., Yousef, M.: One-class SVMs for document classification. J. Mach. Learn. Res. 2(12), 139–154 (2001)
Norouzi, M., Fleet, D.J., Salakhutdinov R.R.: Hamming distance metric learning [C]. In: Advances in Neural Information Processing Systems (NIPS). 061–1069 (2012)
Rai, H., Yadav, A.: Iris recognition using combined support vector machine and Hamming distance approach. Expert Syst. Appl. 41(2), 588–593 (2014)
Kaye, P.: Reversible addition circuit using one ancillary bit with application to quantum computing. arXiv:0408173v2 [quant-ph] (2004)
Grover, L.K.: Quantum mechanics helps in searching for a needle in a haystack. Phys. Rev. Lett. 79(2), 325–328 (1997)
Acknowledgements
This work is supported by the National Natural Science Foundation of China (Grant No. 61170321,61502101), Natural Science Foundation of Jiangsu Province, China (Grant No. BK20140651), Natural Science Foundation of Anhui Province, China (Grant No. 1608085MF129, 1708085MF162), Foundation for Natural Science Major Program of Education Bureau of Anhui Province (Grant No. KJ2015ZD09) and the open fund of Key Laboratory of Computer Network and Information Integration in Southeast University, Ministry of Education, China (Grant No. K93-9-2015-10C).
Author information
Authors and Affiliations
Corresponding author
Rights and permissions
About this article
Cite this article
Ruan, Y., Xue, X., Liu, H. et al. Quantum Algorithm for K-Nearest Neighbors Classification Based on the Metric of Hamming Distance. Int J Theor Phys 56, 3496–3507 (2017). https://doi.org/10.1007/s10773-017-3514-4
Received:
Accepted:
Published:
Issue Date:
DOI: https://doi.org/10.1007/s10773-017-3514-4