Description
Paper Implementation: Distance-Based Classifier with Quantum Interference Circuit
Paper Information
- Title: Implementing a distance-based classifier with a quantum interference circuit
- Authors: Maria Schuld, Mark Fingerhuth, Francesco Petruccione
- arXiv: 1703.10793
- Year: 2017
Problem Statement
This paper presents a novel approach to quantum machine learning by implementing a distance-based binary classifier using a minimal quantum circuit. Unlike other proposals that adapt classical algorithms to quantum computers, this work takes the opposite approach: starting with the simplest possible quantum circuit and developing a classifier around it. The classifier uses quantum interference to compute distances between data points in parallel.
Significance
- The paper demonstrates a practical quantum ML algorithm implementable on near-term quantum devices with minimal resources.
- The classifier was experimentally validated on IBM's 5-qubit quantum computer using the Iris dataset.
- It shows surprisingly good classification performance on benchmark tasks despite its simplicity.
- This implementation could serve as a building block for more complex quantum machine learning systems.
Technical Details
The quantum classifier implements the following binary classification formula:
ỹ = sgn(∑ᵐ yᵐ[1 - (1/4M)|x̃ - xᵐ|²])
where:
- x̃ is the new input to classify
- xᵐ are the training inputs
- yᵐ are the corresponding training labels
- M is the number of training examples
The kernel function κ(x,x') = 1 - (1/4M)|x-x'|² measures similarity between data points.
The quantum implementation requires:
- State preparation: Encoding feature vectors into quantum states
- A quantum circuit with only a Hadamard gate and two measurements
- Post-processing of measurement results
Implementation Plan
Phase 1: Classical Pre-processing
- Implement the standardization and normalization of feature vectors
- Standardize data to zero mean, unit variance
- Normalize each vector to unit length
- Prepare the Iris dataset as used in the paper's experimental demonstration
Phase 2: Core Quantum Circuit Implementation
- Implement the state preparation routine
- Create function to encode feature vectors in quantum states
- Implement the full state preparation as shown in Figure 3 of the paper
- Build the interference circuit
- Create the basic 4-qubit circuit (ancilla, index, data, and class qubits)
- Implement the Hadamard operation and measurement scheme
Phase 3: Classiq-Specific Implementation
- Leverage Classiq's high-level quantum programming features
- Implement the circuit using Classiq's functional modeling approach
- Optimize the circuit for the Classiq platform
- Create utility functions for:
- Calculating rotation angles for amplitude encoding
- Processing measurement results to make classification decisions
- Evaluating classification performance
Phase 4: Testing and Analysis
- Reproduce the Iris dataset experiment from the paper
- Replicate the specific experiment with Iris samples 28, 33, 36, and 85
- Compare with the original results from IBM's quantum computer
- Evaluate performance metrics
- Classification accuracy on the Iris dataset
- Resource requirements and circuit depth
- Compare with classical implementation of the same algorithm
Deliverables
- Complete implementation of the quantum distance-based classifier in Classiq
- Jupyter notebook with:
- Step-by-step implementation walkthrough
- Visualizations of data preprocessing
- Circuit diagrams and explanations
- Experimental results from the Iris dataset classification
- Documentation explaining:
- The theoretical foundation
- Implementation details
- Performance analysis
Expected Challenges
- Efficient amplitude encoding for the feature vectors
- Optimizing the circuit for Classiq's architecture
- Handling the postselection step in the algorithm
Relevance to Classiq
This implementation will showcase Classiq's ability to:
- Build practical quantum machine learning models
- Implement circuits with precise amplitude encoding
- Create reusable quantum modules for machine learning
- Optimize quantum circuits for classification tasks
The minimal resource requirements make this an ideal candidate for early quantum advantage demonstrations, while the performance on real datasets makes it practically relevant.
Timeline
- Week 1: Classical pre-processing and understanding the algorithm
- Week 2: Core quantum circuit implementation in Classiq
- Week 3: Testing and analysis
- Week 4: Documentation and refinement
Possible Extensions
The paper mentions several promising extensions that could be implemented as future enhancements to this core implementation:
-
Polynomial Feature Map: The authors demonstrate that using two copies of each quantum state allows implementation of a polynomial feature map, which can significantly improve classification performance for non-linearly separable datasets (e.g., improving accuracy from 93% to 100% for Iris classes 2 and 3, and enabling classification of concentric circles).
-
Alternative Kernel Functions: Modifying the circuit to realize different kernel functions that allow for more localized distance measures could increase the power and flexibility of the classifier.
-
Entanglement-Based Enhancements: The paper suggests considering circuits that make more use of quantum resources such as entanglement.
These extensions could be considered after successfully implementing the core algorithm.
References
- Schuld, M., Fingerhuth, M., & Petruccione, F. (2017). Implementing a distance-based classifier with a quantum interference circuit. arXiv:1703.10793
- IBM Quantum Experience - Used in the original paper implementation