Curriculum / Quantum Machine Learning / Data Encoding in Practice
Data Encoding in Practice
Compare angle, amplitude, and basis encoding in code experiments.
Data Encoding in Practice
How you encode classical data into quantum states profoundly affects your quantum ML model's performance. This exercise compares three common strategies on the same 2D dataset.
The Three Encoding Strategies
Strategy 1: Angle Encoding (RY only) Map each feature to a Y-rotation:
Two features need 2 qubits. Depth = 1.
Strategy 2: Dense Angle Encoding (RY + RZ) Use both Y and Z rotations to encode more information per qubit:
Two features still need 2 qubits, but the Bloch sphere position is richer.
Strategy 3: IQP Encoding with Interaction Terms Add a cross-term between features via a ZZ interaction:
This creates a feature map that includes the product : a nonlinear correlation.
Why Encoding Depth Matters
More complex encodings create richer feature spaces. But they also:
- •Increase circuit depth (more noise on hardware)
- •Are harder to train (more parameters to distinguish)
- •May cause exponential concentration in kernel values
For NISQ hardware, angle encoding is the practical default. IQP encoding is used for theoretical studies of quantum advantage.
Comparing the Encodings
After encoding data = [0.5, 1.2] into each circuit and measuring:
- •Strategy 1 (angle only): circuit depth 1, product state
- •Strategy 2 (angle + Z phase): circuit depth 2, product state with richer phases
- •Strategy 3 (IQP interaction): circuit depth 3+, entangled state
Each encoding strategy trades depth for expressibility. Strategy 1 is shallowest (noise-friendly) but has limited feature interactions. Strategy 3 is deepest (noise-sensitive) but captures pairwise feature correlations. On today's NISQ hardware, shallower circuits usually win because noise destroys the advantage of deeper feature maps before the measurement. As hardware improves, richer encodings will become practical.
How this lesson works
A hands-on coding challenge. You write Qiskit-compatible Python in the browser editor, run it instantly via WebAssembly, watch the circuit and Bloch sphere react, and pass automatic output checks. The AI tutor Qubitus gives Socratic hints if you get stuck.
Part of: Quantum Machine Learning
Apply quantum computing to machine learning with variational circuits and optimization.
This lesson is part of Pro
Unlock Quantum Machine Learning and all 10 tracks with Pro: $12.99/month, $79/year, or $97 lifetime. Start with the free track first if you are new.