First time studying this topic?

Launch the interactive walkthrough to discover each component, including the 3D Q-Sphere Lab & Python in Colab.

Topic 8.5

Quantum Feature Maps & Non-Linear Embeddings

Understand how quantum feature maps project classical data into exponentially large Hilbert spaces to make non-linear data linearly separable.

Learning Objectives

  • ✓Define the Quantum Feature Map: Phi(x) -> |Phi(x)>
  • ✓Understand the Kernel Trick in Quantum Hilbert Spaces
  • ✓Construct Havlicek-style entangling feature maps (ZZFeatureMap in Qiskit)

📖Let's Begin with a Story

In 1992, computer scientists working on Support Vector Machines (SVMs) realized a brilliant trick: If data points in 2D cannot be separated by a straight line (for example, red dots inside a blue ring), you can project the points into a higher 3D dimension: z=x2+y2z = x^2 + y^2 Suddenly, the inner red dots rise up into a 3D bowl, and a flat sheet of paper (a hyperplane) can cleanly slice between red and blue! In classical ML, computing these high-dimensional spaces becomes impossibly expensive when dimensions exceed thousands. Quantum Feature Maps take this idea to its ultimate physical conclusion: they map classical data into a **2n2^n-dimensional quantum Hilbert space** using entangling gates. Spaces with billions of dimensions can be manipulated using just 30 qubits!

Why Should You Learn Quantum Feature Maps & Non-Linear Embeddings?

🎯 Practical & Engineering Stakes

The theoretical heart of Quantum Advantage in ML

Havlicek et al. (Nature 2019) proved that certain entangling quantum feature maps create feature spaces that are provably intractable to estimate or simulate on any classical computer.

What Is It?

Simple Explanation

Think of a messy knotted tangled rope on a table. In 2D, the knot seems impossible to untangle. If you pick the rope up into 3D space, the knot easily pulls apart! Quantum Feature Maps pick up your tangled classical data and lift it into a vast 2^n-dimensional quantum space where complex patterns untangle into simple straight lines!

Technical Explanation

A Quantum Feature Map is a non-linear embedding Φ:X→H\Phi: \mathcal{X} \rightarrow \mathcal{H} implemented by a unitary circuit UΦ(x)∣0⟩⊗n=∣Φ(x)⟩U_\Phi(\mathbf{x})|0\rangle^{\otimes n} = |\Phi(\mathbf{x})\rangle. The canonical Havlicek ZZ-feature map applies single-qubit Hadamard and phase rotations, followed by two-qubit entangling phase gates UZZ=exp⁡(i(π−xj)(π−xk)ZjZk)U_{ZZ} = \exp(i (\pi - x_j)(\pi - x_k) Z_j Z_k), creating non-classical correlations conjectured to be classically intractable to sample.

📚 Key Terms

Quantum Feature Map

Simple: A circuit that transforms classical data into an entangled quantum state.
Technical: Unitary transformation UΦ(x)U_\Phi(\mathbf{x}) mapping Rd\mathbb{R}^d to state vectors ∣Φ(x)⟩|\Phi(\mathbf{x})\rangle.

ZZFeatureMapZZFeatureMap

Simple: A famous quantum feature map from IBM that entangles pairs of qubits based on product features.
Technical: Second-order Pauli expansion feature map generating non-linear feature cross-products via Z⊗ZZ \otimes Z interactions.

Q-Sphere Lab: Quantum Feature Maps & Non-Linear Embeddings

IBM Q-Sphere Model

Interactive 3D state vector exploration, unitary transformation gates, and Born rule collapse for Topic 8.5

Azimuth: 45°Elevation: 25°
+Z |0⟩-Z |1⟩+X |+⟩+Y |+i⟩01|ψ⟩
Q-Sphere Phase Color:
0 π/2 π 3π/2

Quantum Statevector

dim(H) = 2
|ψ⟩ = (1.000 + 0.000i)|0⟩
     + (0.000 + 0.000i)|1⟩
Polar Angle (θ):0.0° (0.000π rad)
Phase Angle (ϕ):0.0° (0.000π rad)

Born Rule Probabilities: P(x) = |⟨x|ψ⟩|²Σ P = 1.00

P(|0⟩) = |α|²100.0%
P(|1⟩) = |β|²0.0%
Quantum Measurement

Apply Single-Qubit Unitary Gates

Presets:
Continuous Polar Angle θ (0° = |0⟩, 180° = |1⟩):0.0°
Continuous Phase Angle ϕ (0° to 360°):0.0°
Recent Operations Log:
#1Initial state: |0⟩

📐 Mathematical Foundation

LaTeX KaTeX
UΦ(x)=exp⁡(i∑j=1nxjZj+i∑j<kn(π−xj)(π−xk)ZjZk)H⊗nU_{\Phi}(\mathbf{x}) = \exp\left( i \sum_{j=1}^n x_j Z_j + i \sum_{j < k}^n (\pi - x_j)(\pi - x_k) Z_j Z_k \right) H^{\otimes n}

What does it mean?

The Havlicek ZZ-Feature Map (IBM Quantum): Maps classical data into non-linearly entangled quantum states. By combining initial Hadamard superpositions with single-qubit phase rotations and two-qubit Z_j Z_k entangling interactions whose phases scale as (pi - x_j)(pi - x_k), this feature map creates quantum correlations that are proven to be classically hard to simulate.

Understanding the Symbols

Symbol / TermMeaningBeginner Interpretation
UΦ(x)U_\Phi(\mathbf{x})Non-linear feature map unitaryPrepares the quantum feature state ∣Φ(x)⟩=UΦ(x)∣0⟩otimesn|\Phi(\mathbf{x})\rangle = U_{\Phi}(\mathbf{x})|0\rangle^{otimes n}
H⊗nH^{\otimes n}Layer of Hadamard gatesInitializes all qubits into uniform quantum superposition
ZjZ_jPauli-Z operator on qubit jEncodes individual feature xjx_j into single-qubit phase
ZjZkZ_j Z_kTwo-qubit Ising couplingEncodes non-linear cross-product interaction between features j and k

📊 Numerical Example

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:

Step 1: Compute Single-Qubit Rotation Angles: θ_1 = 2 × x1 = 2 × 0.5 = 1.00 radian (57.3°) θ_2 = 2 × x2 = 2 × 1.2 = 2.40 radians (137.5°) Step 2: Compute Two-Qubit Non-linear Entangling Phase: Phase_12 = 2 × (π - x1) × (π - x2) π - x1 = 3.1416 - 0.5 = 2.6416 π - x2 = 3.1416 - 1.2 = 1.9416 Phase_12 = 2 × (2.6416 × 1.9416) = 2 × 5.1289 = 10.2578 radians Step 3: Modulo 2π Reduction for Hardware Execution: 10.2578 mod 2π = 10.2578 - 6.2832 = 3.9746 radians (227.7°) Step 4: Circuit Implementation: Synthesized using CNOT(0, 1) -> Rz(3.9746, 1) -> CNOT(0, 1)

Result: The non-linear product of features x1 and x2 is mapped directly into an entangled 2-qubit relative phase of 3.9746 radians.

⚙️ How Does It Work?

1

Hadamard Initialization

Create uniform superposition across all qubits.

2

Linear Phase Encoding

Apply Rz(2*x_i) rotations on individual qubits.

3

Entangling Interaction

Apply CNOT-Rz-CNOT sequences between qubit pairs to encode feature products x_i * x_j.

4

Repetition (Layers)

Repeat the block d times to increase expressibility.

🌍 Where Is It Used?

Complex Pattern Classification

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.

🎯 Try It Yourself

Why does the ZZFeatureMap include two-qubit entangling gates (like CNOT or Rzz) between qubits rather than only single-qubit rotations?

Interactive activity component

🐍 Python Hands-On: Constructing the ZZFeatureMap and PauliFeatureMap in Qiskit

Build industry-standard Qiskit feature maps with second-order Pauli expansion and analyze entangling gate structures.

Open Colab

1Install Required Packages

For Google Colab or Jupyter notebooks, run this shell command to install the required dependencies:

Terminal / Notebook Install Commandbash
!pip install qiskit
Packages:
qiskit

2Import Libraries

Import Statementspython
1from qiskit.circuit.library import ZZFeatureMap, ZFeatureMap

from qiskit.circuit.library import ZZFeatureMap, ZFeatureMap → Qiskit feature map library

3Demonstration Code & Logic

Python Execution Codepython
1# 1. ZFeatureMap: First-order feature map (no entanglement)
2z_map = ZFeatureMap(feature_dimension=3, reps=1)
3print('=== 1. ZFeatureMap (First-Order / Separable) ===')
4print(z_map.decompose().draw('text'))
5
6# 2. ZZFeatureMap: Second-order feature map (with CNOT-entangled non-linear interactions)
7zz_map = ZZFeatureMap(feature_dimension=3, reps=1, entanglement='linear')
8print('\n=== 2. ZZFeatureMap (Second-Order / Entangled) ===')
9print(zz_map.decompose().draw('text'))
10print('\nNotice: The ZZFeatureMap adds CNOT-Rz-CNOT blocks between adjacent qubits,')
11print('encoding cross-product features 2*(pi-x0)*(pi-x1) that are hard to simulate classically!')
Step-by-Step Code Breakdown:

# 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

📋 Complete Script (All-in-One)

Click "Copy for Colab", open Google Colab, paste into a single cell, and run.

Google Colab Notebook Scriptpython
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
10from qiskit.circuit.library import ZZFeatureMap, ZFeatureMap
11
12# Step 3: Run Demonstration
13# 1. ZFeatureMap: First-order feature map (no entanglement)
14z_map = ZFeatureMap(feature_dimension=3, reps=1)
15print('=== 1. ZFeatureMap (First-Order / Separable) ===')
16print(z_map.decompose().draw('text'))
17
18# 2. ZZFeatureMap: Second-order feature map (with CNOT-entangled non-linear interactions)
19zz_map = ZZFeatureMap(feature_dimension=3, reps=1, entanglement='linear')
20print('\n=== 2. ZZFeatureMap (Second-Order / Entangled) ===')
21print(zz_map.decompose().draw('text'))
22print('\nNotice: The ZZFeatureMap adds CNOT-Rz-CNOT blocks between adjacent qubits,')
23print('encoding cross-product features 2*(pi-x0)*(pi-x1) that are hard to simulate classically!')
⚡ How to Run in Google Colab (3 Quick Steps)
  1. Click "Copy for Google Colab" above.
  2. Click Open New Google Colab Notebook (opens in a new tab).
  3. Click on the first empty code cell, press Ctrl + V (or Cmd + V) to paste, then press Shift + Enter to execute!

🔄 Algorithmic Execution Flow

1
First-Order Z-Map

Applies Hadamard followed by Rz(2*x_i) on each qubit independently.

→
2
Second-Order ZZ-Map

Inserts two-qubit entangling gates CNOT-Rz-CNOT encoding pairwise interactions.

→
3
Expressibility Comparison

Shows how the ZZFeatureMap creates non-classical quantum correlations.

📥 Input / Initial State
3-dimensional feature space configured with Z and ZZ feature maps.
📤 Expected Output
ZFeatureMap: 3 independent Rz wires.
ZZFeatureMap: 3 wires with interleaved CNOT-Rz-CNOT interactions across pairs (0,1) and (1,2).
💡 What Does This Demonstration Show?

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.

Course Learning Resource • Slide DeckLesson 1011 Slides

Lesson 10: Variational Quantum Classification

Feature maps, ansatz, COBYLA optimization, and complete VQC pipeline.

Author: Dr. Syed Muzamil Basha• FDP Approved Curriculum
Open in New Tab

📝 Learning Check

Test your understanding with these questions. Remember, this is for learning, not examination!

Question 1: What is the primary advantage of mapping classical data into a high-dimensional Quantum Hilbert Space?

Question 2: Placeholder question 2

Question 3: Placeholder question 3

Question 4: Placeholder question 4

Question 5: Placeholder question 5