Curriculum / Quantum Machine Learning / Quantum Data Encoding Strategies

Lesson 3 of 15ReadingPro+100 XP

Quantum Data Encoding Strategies

Basis, amplitude, and angle encoding, how to get classical data into qubits.

Quantum Data Encoding Strategies

One of the central challenges in quantum machine learning is data encoding: how do you get classical data into a quantum computer? The encoding method directly affects what your quantum model can learn and how efficiently it runs.

Why Encoding Matters

A quantum circuit operates on quantum states, not classical bits. Before any quantum processing, classical data must be converted into a quantum state. This mapping is the feature map, and it determines the geometry of the quantum feature space.

Poor encoding can destroy all structure in the data. Good encoding preserves and amplifies the patterns your model needs to detect.

Strategy 1: Basis Encoding

Basis encoding stores classical bits directly in computational basis states:

x = [1, 0, 1] --> |101>

For binary data, this is natural: each bit becomes a qubit. For real-valued data, you first discretize (quantize) the values.

Pros: Simple, exact for binary data. Cons: Requires one qubit per bit. For 32-bit floating-point numbers, you need 32 qubits per feature. Exponentially expensive for continuous data.

Strategy 2: Angle Encoding

Angle encoding maps each feature value to a rotation angle:

This is the most common encoding in near-term QML. For n features, you need n qubits. The feature value directly controls the rotation angle, which determines the qubit's Bloch sphere position.

Pros: Efficient (1 qubit per feature). Naturally continuous. Differentiable with respect to data. Cons: Linear encoding: the feature space is the surface of n independent Bloch spheres. Limited expressibility for complex data.

Strategy 3: Amplitude Encoding

Amplitude encoding stores all N feature values in the amplitudes of a quantum state:

This requires only log2(N) qubits to store N features: exponential compression! For 1024 features, you only need 10 qubits.

This is the opening of the lesson. The full walkthrough, the interactive circuit, and the graded challenge continue inside myqubit.

How this lesson works

A guided reading lesson with interactive knowledge checks. Concepts are explained step by step with circuit diagrams and runnable examples, and you confirm understanding before moving on.

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.