Quantum Kernel SVM
Overview
Combines quantum feature maps with classical Support Vector Machines for classification. The quantum kernel measures similarity in exponentially large Hilbert space.
| Property | Value |
|---|---|
| Category | Machine Learning |
| Difficulty | Advanced |
| Framework | PennyLane |
| Qubits | 4 |
| Depth | ~10 |
| Gates | RX, RY, RZ, CNOT |
The Quantum Kernel
Feature Map
Classical data x → Quantum state |φ(x)⟩
Kernel Function
CODEK(x, y) = |⟨φ(x)|φ(y)⟩|²
Classification
SVM finds hyperplane in feature space maximizing margin.
Circuit Structure
ZZ-Feature Map:
CODE┌───┐┌────────┐ ┌────────────┐ q_0: ┤ H ├┤ RZ(x₀π)├──■──┤ RZ(x₀x₁π) ├──■── ├───┤├────────┤┌─┴─┐└────────────┘ │ q_1: ┤ H ├┤ RZ(x₁π)├┤ X ├───────────────┼── ├───┤├────────┤└───┘ │ q_2: ┤ H ├┤ RZ(x₀π)├────────────────────┼── ├───┤├────────┤ ┌─┴─┐ q_3: ┤ H ├┤ RZ(x₁π)├──────────────────┤ X ├ └───┘└────────┘ └───┘
Running the Circuit
PYTHONfrom circuit import run_circuit result = run_circuit(n_samples=20, n_qubits=4) print(f"Accuracy: {result['accuracy']:.2%}") print(f"Support vectors: {result['n_support_vectors']}")
Expected Output
| Metric | Value |
|---|---|
| Accuracy | 80-95% |
| Support vectors | 3-8 |
| Kernel evaluation | O(n²) |
Training Process
- Compute kernel matrix: K[i,j] = K(xᵢ, xⱼ)
- Solve SVM dual: Find optimal αᵢ
- Identify support vectors: Points with αᵢ > 0
- Predict: f(x) = Σαᵢyᵢk(x, xᵢ) + b
Advantages
| Aspect | Classical RBF | Quantum Kernel |
|---|---|---|
| Feature dimension | Infinite | 2ⁿ |
| Expressibility | Fixed form | Tunable |
| Potential advantage | None | Possible for some data |
Applications
- Classification: Binary and multi-class
- Anomaly detection: One-class SVM
- Feature selection: Kernel PCA
- Clustering: Spectral methods