Skip to main content
QUICK REVIEW

[Paper Review] Quantum K-nearest neighbor classification algorithm based on Hamming distance

Jing Li, Song Lin|arXiv (Cornell University)|Mar 7, 2021
Quantum Computing Algorithms and ArchitectureComputer Science5 citations
TL;DR

This paper proposes a quantum K-nearest neighbor (KNN) classification algorithm based on Hamming distance, leveraging quantum parallelism to compute distances and a novel quantum sub-algorithm to efficiently find the K smallest distances. The method achieves quadratic speedup over classical KNN, with time complexity O(√M log M) in low-dimensional feature spaces.

ABSTRACT

K-nearest neighbor classification algorithm is one of the most basic algorithms in machine learning, which determines the sample's category by the similarity between samples. In this paper, we propose a quantum K-nearest neighbor classification algorithm with Hamming distance. In this algorithm, quantum computation is firstly utilized to obtain Hamming distance in parallel. Then, a core sub-algorithm for searching the minimum of unordered integer sequence is presented to find out the minimum distance. Based on these two sub-algorithms, the whole quantum frame of K-nearest neighbor classification algorithm is presented. At last, it is shown that the proposed algorithm can achieve a quadratical speedup by analyzing its time complexity briefly.

Motivation & Objective

  • To address the limitations of existing quantum KNN algorithms that rely on Euclidean distance and require tuning of multiple parameters.
  • To develop a quantum algorithm tailored for non-numerical, binary-encoded data using Hamming distance as the similarity metric.
  • To design an efficient quantum sub-algorithm for finding the K smallest distances in an unordered sequence of integers.
  • To construct a complete quantum framework for KNN classification that integrates distance computation and category assignment using quantum operations.
  • To demonstrate significant speedup over classical KNN by analyzing time complexity in low-dimensional feature spaces.

Proposed method

  • Utilizes quantum random access memory (vQRAM) to prepare the initial quantum state encoding training samples and the test sample.
  • Employs a quantum circuit based on CNOT and incrementer gates to compute Hamming distances in parallel across all training samples.
  • Introduces a novel quantum algorithm to find the K smallest values in an unordered integer sequence, optimized for integer data and more efficient than Dürr-Høyer minimization.
  • Applies amplitude amplification and amplitude estimation techniques to identify the K nearest neighbors by repeatedly finding the minimum distance.
  • Uses a controlled oracle and quantum measurement to determine the most frequent class among the K nearest neighbors via majority voting.
  • Employs quantum state preparation and measurement to assign the final class label based on the frequency of categories in the K nearest neighbors.

Experimental results

Research questions

  • RQ1Can a quantum KNN algorithm based on Hamming distance be designed to handle non-numerical, binary-encoded data more effectively than existing quantum approaches?
  • RQ2Can a quantum sub-algorithm be developed that efficiently finds the K smallest values in an unordered integer sequence, outperforming general-purpose quantum minimization techniques?
  • RQ3Does the proposed quantum KNN framework achieve a provable speedup over classical KNN in terms of time complexity?
  • RQ4How does the time complexity of the quantum algorithm scale with respect to the number of training samples M, dimensionality N, and number of neighbors K?
  • RQ5What are the practical limitations of the algorithm, particularly when dealing with high-dimensional data?

Key findings

  • The proposed quantum KNN algorithm achieves a time complexity of O(√M log M) in low-dimensional feature spaces, representing a quadratic speedup over the classical O(M) complexity.
  • The quantum Hamming distance computation is performed in parallel using N CNOT gates and Nn² incrementer operations, with runtime O(N + Nn²).
  • The core sub-algorithm for finding the K smallest distances operates in O(Kn³ log N / √M) time, which is more efficient than the Dürr-Høyer minimization for integer sequences.
  • The category assignment step requires O(K log K) measurements to identify the most frequent class among K nearest neighbors with high probability.
  • The overall time complexity is dominated by the K-minimum search step, and the algorithm maintains quadratic speedup as long as K and N are small relative to M.
  • The algorithm is not quadratically accelerated in high-dimensional feature spaces, indicating a key limitation for future work on dimensionality scaling.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.