Launch the interactive walkthrough to discover each component, including the 3D Q-Sphere Lab & Python in Colab.
Understand how quantum feature maps project classical data into exponentially large Hilbert spaces to make non-linear data linearly separable.
Interactive 3D state vector exploration, unitary transformation gates, and Born rule collapse for Topic 8.5
| Symbol / Term | Meaning | Beginner Interpretation |
|---|---|---|
| Non-linear feature map unitary | Prepares the quantum feature state | |
| Layer of Hadamard gates | Initializes all qubits into uniform quantum superposition | |
| Pauli-Z operator on qubit j | Encodes individual feature into single-qubit phase | |
| Two-qubit Ising coupling | Encodes non-linear cross-product interaction between features j and k |
Computing the non-linear entangling phase for a 2-feature data sample x1 = 0.5 and x2 = 1.2 in a 2-qubit ZZ-Feature Map:
Result: The non-linear product of features x1 and x2 is mapped directly into an entangled 2-qubit relative phase of 3.9746 radians.
Create uniform superposition across all qubits.
Apply Rz(2*x_i) rotations on individual qubits.
Apply CNOT-Rz-CNOT sequences between qubit pairs to encode feature products x_i * x_j.
Repeat the block d times to increase expressibility.
Problem: Classifying non-linearly separable datasets (e.g. concentric circles or spirals).
Solution: ZZFeatureMap lifts concentric circles into Hilbert space where a linear quantum hyperplane cleanly separates classes.
Interactive activity component
Build industry-standard Qiskit feature maps with second-order Pauli expansion and analyze entangling gate structures.
For Google Colab or Jupyter notebooks, run this shell command to install the required dependencies:
!pip install qiskit1 from qiskit.circuit.library import ZZFeatureMap, ZFeatureMap
from qiskit.circuit.library import ZZFeatureMap, ZFeatureMap → Qiskit feature map library
1 # 1. ZFeatureMap: First-order feature map (no entanglement) 2 z_map = ZFeatureMap(feature_dimension=3, reps=1) 3 print('=== 1. ZFeatureMap (First-Order / Separable) ===') 4 print(z_map.decompose().draw('text')) 5 6 # 2. ZZFeatureMap: Second-order feature map (with CNOT-entangled non-linear interactions) 7 zz_map = ZZFeatureMap(feature_dimension=3, reps=1, entanglement='linear') 8 print('\n=== 2. ZZFeatureMap (Second-Order / Entangled) ===') 9 print(zz_map.decompose().draw('text')) 10 print('\nNotice: The ZZFeatureMap adds CNOT-Rz-CNOT blocks between adjacent qubits,') 11 print('encoding cross-product features 2*(pi-x0)*(pi-x1) that are hard to simulate classically!')
# 1. ZFeatureMap: First-order feature map (no entanglement)
ZFeatureMap
z_map = ZFeatureMap(feature_dimension=3, reps=1)
3 features, 1 repetition
print('=== 1. ZFeatureMap (First-Order / Separable) ===')
Header 1
print(z_map.decompose().draw('text'))
Print circuit
# 2. ZZFeatureMap: Second-order feature map (with CNOT-entangled non-linear interactions)
ZZFeatureMap
zz_map = ZZFeatureMap(feature_dimension=3, reps=1, entanglement='linear')
3 features with entangling gates
print('\n=== 2. ZZFeatureMap (Second-Order / Entangled) ===')
Header 2
print(zz_map.decompose().draw('text'))
Print circuit
print('\nNotice: The ZZFeatureMap adds CNOT-Rz-CNOT blocks between adjacent qubits,')
Note 1
print('encoding cross-product features 2*(pi-x0)*(pi-x1) that are hard to simulate classically!')
Note 2
Click "Copy for Colab", open Google Colab, paste into a single cell, and run.
1 # ========================================================= 2 # Constructing the ZZFeatureMap and PauliFeatureMap in Qiskit 3 # Prepared for Google Colab (Run with Shift + Enter) 4 # ========================================================= 5 6 # Step 1: Install required packages 7 !pip install qiskit 8 9 # Step 2: Import libraries 10 from qiskit.circuit.library import ZZFeatureMap, ZFeatureMap 11 12 # Step 3: Run Demonstration 13 # 1. ZFeatureMap: First-order feature map (no entanglement) 14 z_map = ZFeatureMap(feature_dimension=3, reps=1) 15 print('=== 1. ZFeatureMap (First-Order / Separable) ===') 16 print(z_map.decompose().draw('text')) 17 18 # 2. ZZFeatureMap: Second-order feature map (with CNOT-entangled non-linear interactions) 19 zz_map = ZZFeatureMap(feature_dimension=3, reps=1, entanglement='linear') 20 print('\n=== 2. ZZFeatureMap (Second-Order / Entangled) ===') 21 print(zz_map.decompose().draw('text')) 22 print('\nNotice: The ZZFeatureMap adds CNOT-Rz-CNOT blocks between adjacent qubits,') 23 print('encoding cross-product features 2*(pi-x0)*(pi-x1) that are hard to simulate classically!')
Applies Hadamard followed by Rz(2*x_i) on each qubit independently.
Inserts two-qubit entangling gates CNOT-Rz-CNOT encoding pairwise interactions.
Shows how the ZZFeatureMap creates non-classical quantum correlations.
3-dimensional feature space configured with Z and ZZ feature maps.
ZFeatureMap: 3 independent Rz wires. ZZFeatureMap: 3 wires with interleaved CNOT-Rz-CNOT interactions across pairs (0,1) and (1,2).
The ZZFeatureMap is conjectured to be classically intractable to evaluate for large qubit numbers. It forms the standard feature extractor in quantum support vector machines.
Feature maps, ansatz, COBYLA optimization, and complete VQC pipeline.
Test your understanding with these questions. Remember, this is for learning, not examination!