Project 11: Quantum Machine Learning (QML) - Kernel Methods
Build a quantum kernel demo and compare it to a classical kernel.
Project Overview
| Attribute | Value |
|---|---|
| Difficulty | Level 3: Advanced |
| Time Estimate | 1-2 weeks |
| Main Language | Python |
| Alternative Languages | Julia, R |
| Knowledge Area | Quantum machine learning |
| Tools | Qiskit or Cirq |
| Main Book | “Quantum Machine Learning” by Maria Schuld and Francesco Petruccione |
What you’ll build: A small dataset classification demo using a quantum kernel and a classical SVM.
Why it teaches quantum: QML is mostly about feature maps and kernel evaluation via circuits.
Core challenges you’ll face:
- Building a feature map circuit
- Estimating kernel entries via circuit overlaps
- Comparing to classical baselines
Real World Outcome
You will train a kernel classifier and report accuracy compared to a classical kernel.
Example Output:
$ python qml_kernel.py --dataset moons
Quantum kernel accuracy: 0.86
Classical RBF accuracy: 0.84
Verification steps:
- Ensure kernel matrix is symmetric and positive semi-definite
- Compare results over multiple runs
The Core Question You’re Answering
“How can a quantum circuit define a feature space for classification?”
This is the heart of quantum kernel methods.
Concepts You Must Understand First
Stop and research these before coding:
- Kernel methods
- Why do kernels replace explicit feature maps?
- Book Reference: “Quantum Machine Learning” by Schuld & Petruccione, Ch. 6
- Feature map circuits
- How do you encode classical data into quantum states?
- Book Reference: “Quantum Machine Learning” by Schuld & Petruccione, Ch. 4
- Kernel estimation
- How do you estimate overlaps using circuits?
- Book Reference: “Quantum Machine Learning” by Schuld & Petruccione, Ch. 6
Questions to Guide Your Design
- Dataset choice
- Which small dataset will you use (moons, circles)?
- How will you normalize features?
- Evaluation
- How will you compare to classical kernels fairly?
- Will you report accuracy or F1?
Thinking Exercise
Kernel Symmetry
Why must the kernel matrix be symmetric? What would it mean if it isn’t?
Questions while working:
- How does symmetry relate to inner products?
- What does positive semi-definite imply?
The Interview Questions They’ll Ask
Prepare to answer these:
- “What is a kernel method?”
- “How do quantum kernels work?”
- “What is a feature map in QML?”
- “How do you estimate kernel entries?”
- “What are the limitations of QML today?”
Hints in Layers
Hint 1: Starting Point Start with a tiny dataset and 2 qubits.
Hint 2: Next Level Compute the kernel matrix on a simulator.
Hint 3: Technical Details Use the kernel matrix as input to a classical SVM.
Hint 4: Tools/Debugging Check kernel symmetry and eigenvalues.
Books That Will Help
| Topic | Book | Chapter |
|---|---|---|
| Kernel methods | Schuld & Petruccione | Ch. 6 |
| Feature maps | Schuld & Petruccione | Ch. 4 |
| Kernel estimation | Schuld & Petruccione | Ch. 6 |
Implementation Hints
- Keep datasets small to reduce kernel computation time.
- Use a classical SVM as baseline.
- Repeat runs to account for sampling noise.
Learning Milestones
- First milestone: You can build a feature map circuit.
- Second milestone: You can compute a quantum kernel matrix.
- Final milestone: You can compare quantum vs classical performance.