Quantum Machine Learning Data Encoding: A Guide to Angle, Amplitude, and Basis Embedding
quantum-machine-learningdata-encodingfeature-mapspennylaneqiskitqml-tutorial

Quantum Machine Learning Data Encoding: A Guide to Angle, Amplitude, and Basis Embedding

SSmartQbit Editorial Team
2026-11-13
8 min read

Compare basis, angle, amplitude, and feature-map encoding with practical qubit, depth, normalization, and workload estimates.

Choosing a data-encoding strategy is one of the first design decisions in a quantum machine learning pipeline. This guide shows how to compare basis, angle, amplitude, and feature-map encoding, estimate qubit and circuit requirements, apply the right preprocessing, and build a small test before committing to a larger experiment.

Overview

Quantum data encoding is the process of mapping classical features into a quantum state or into gate parameters. A quantum model cannot consume a spreadsheet row directly: the row must be represented by qubit states, rotation angles, or amplitudes before a variational circuit can process it.

There is no universally best encoding. The appropriate choice depends on the number of features, the available qubits, the acceptable circuit depth, the scale and meaning of the data, and whether the experiment will run on a simulator or real hardware. Encoding can also become a substantial part of the workload. A compact representation may require more gates, while a shallow representation may use more qubits or discard information.

The main options are:

  • Basis encoding: represents binary values with computational-basis states such as |0⟩ and |1⟩.
  • Angle encoding: maps normalized feature values to rotation angles on one or more qubits.
  • Amplitude encoding: stores a normalized feature vector in the amplitudes of a quantum state.
  • Feature-map encoding: uses a structured sequence of gates, often including single-qubit rotations and entangling operations, to transform classical features into a circuit state.

For most first experiments, angle encoding or a simple feature map is easier to inspect and debug than amplitude encoding. Basis encoding is useful when the data is naturally binary. Amplitude encoding can reduce the number of qubits in the state representation, but state preparation and normalization must be treated as first-class costs rather than hidden implementation details.

How to estimate

Estimate an encoding by separating four quantities: qubits, encoded feature groups, circuit depth, and execution workload. Write these estimates down before selecting an SDK implementation so that a framework change does not change the experiment's definition.

1. Estimate the qubit requirement

For basis encoding, the qubit count depends on how many binary variables must be represented. A direct one-feature-per-qubit approach uses approximately one qubit per binary feature. If a binary string represents an integer or category, a compact binary representation may use approximately the ceiling of log2(K) qubits for K possible values, but the unused states and category semantics need to be handled explicitly.

For angle encoding, a common starting estimate is one qubit per feature when each feature controls one rotation. If there are more features than available qubits, divide the input into groups or encode multiple features in successive layers. That reduces the qubit requirement but increases circuit depth and may change the model's behavior.

For amplitude encoding, a state with 2n amplitudes uses n qubits. Therefore, a vector of length D needs a number of qubits related to the smallest power of two that can contain D values. If D is not a power of two, pad the vector according to a documented rule. Fewer qubits do not automatically mean a cheaper experiment: preparing an arbitrary amplitude state can require a nontrivial gate sequence.

Feature maps usually use the number of qubits as the number of features per layer, although implementations differ. When the feature count exceeds the available qubits, decide whether features will be reduced, grouped, reused across layers, or represented through a different map.

2. Estimate circuit depth

Count the operations introduced by encoding separately from the trainable ansatz. For a simple angle map, the encoding cost may be close to one rotation per feature per layer. A map with entanglers adds two-qubit gates, and repeated data-reuploading layers multiply both the encoding and entangling cost.

A practical estimate can use this worksheet:

  • Encoding layers: L.
  • Features represented per layer: F.
  • Single-qubit encoding operations: approximately L × F for a one-operation-per-feature design.
  • Entangling operations: count the links in the chosen connectivity pattern for each layer.
  • Total depth: measure the compiled circuit as well as the abstract circuit, because hardware-aware compilation can change the schedule.

These are planning estimates, not performance guarantees. The final depth depends on the gate set, connectivity, transpiler or compiler settings, and whether operations can run in parallel.

3. Estimate execution workload

For a variational quantum machine learning model, the workload is not just one circuit execution. A useful first approximation is:

total circuit evaluations ≈ training steps × parameter evaluations per step × shots per evaluation

Parameter evaluations vary by optimizer and gradient method. If a circuit has P trainable parameters and the chosen gradient procedure evaluates several shifted or perturbed circuits per parameter, the evaluation count can grow quickly. Include validation and test passes separately. Also account for repeated measurements when estimating queue time or cloud usage.

Inputs and assumptions

Before encoding data, create a small data contract. It should state the feature order, data types, scaling method, missing-value policy, padding rule, and label handling. This prevents a model from appearing reproducible while silently receiving different inputs.

Basis encoding

Use basis encoding for genuinely discrete or binary data. Convert each value to a defined bit representation and document the ordering. Do not treat a continuous measurement as binary without considering what information the threshold removes. For categorical variables, define whether the category is ordinal, one-hot, or represented by a compact code; a compact code can introduce a numerical relationship that may not exist in the original categories.

Angle encoding

Scale features before converting them to angles. A typical workflow maps a bounded feature x to an interval such as [0, π] or [-π, π], then applies a rotation gate. The interval is a modeling choice, so record it with the experiment. Standardization alone does not guarantee a suitable angle range; it may need to be followed by clipping or a bounded transformation.

Keep the mapping consistent between training, validation, and production data. If a feature is scaled using statistics from the full dataset instead of the training split, the encoding can leak information from evaluation data into training.

Amplitude encoding

Amplitude encoding requires a vector with a valid norm, commonly normalized so that the sum of squared amplitudes equals one. Normalize each input according to a fixed rule, and decide how zero vectors, outliers, signs, and padding are handled. A normalization step can remove overall magnitude information. If magnitude is predictive, preserve it as an additional feature or use an alternative encoding.

Record the state-preparation method and include it in resource estimates. The state-preparation circuit is part of the algorithm, not merely a data-loading detail.

Feature maps

A feature map combines encoding and circuit structure. It may apply rotations, nonlinear angle functions, repeated data layers, or entanglers. Compare maps using the same preprocessing, train-validation split, optimizer budget, and measurement procedure. Otherwise, an apparent improvement may come from a different data pipeline or a larger evaluation budget rather than from the map itself.

Framework APIs change over time, so pin the SDK version in experiments and verify the current constructor, gate convention, parameter order, and transpilation behavior. PennyLane, Qiskit, and Cirq can express similar ideas with different abstractions; an equivalent-looking circuit may not have identical ordering or compiled depth.

Worked examples

Example 1: eight bounded numerical features

Suppose a dataset contains eight numerical features, each transformed to the interval [0, π]. A direct angle-encoding baseline uses eight qubits and one rotation per feature in one encoding layer. Add a trainable ansatz with one layer, then measure the observable required by the classifier. The baseline estimate is eight qubits, eight feature rotations, and the ansatz operations, before compilation.

If only four qubits are available, split the features into two groups and apply two data-reuploading layers. This keeps the qubit count near four but increases depth. It also means the model no longer sees all eight features simultaneously in the same encoding layer. Compare this design against a classical dimensionality-reduction baseline and document the grouping order.

Example 2: a sixteen-value feature vector

A vector of length 16 fits naturally into an amplitude representation using four qubits because 24 equals 16. First apply the chosen normalization, then prepare the state, and then run the trainable circuit. The qubit estimate is attractive, but the state-preparation circuit may dominate the total depth. A fair comparison with angle encoding must include those preparation gates and use the same shot and training budgets.

Example 3: binary inputs

For six binary indicators, a direct basis encoding can use six qubits. A simple circuit prepares each qubit in |0⟩ or |1⟩ according to the input, followed by the model circuit. This is a transparent baseline for testing whether a quantum model can learn from the data at all. If the indicators are sparse, also test whether the chosen representation creates unnecessary circuit activity or whether a compact encoding is easier to maintain.

A minimal implementation pattern

Keep preprocessing outside the quantum circuit and make the encoding function explicit. In pseudocode:

fit scaler on training features
transform training, validation, and test data
for each sample:
validate feature count and finite values
apply the documented encoding map
execute the circuit with a fixed shot policy
convert measurements to model features or a prediction

This separation makes it easier to test the classical transformation independently, compare encodings, and identify whether a poor result comes from preprocessing, state preparation, optimization, or measurement noise.

When to recalculate

Recalculate the encoding estimate whenever the dataset, hardware target, or training procedure changes. A new feature count can alter qubits and depth; a new normalization rule can alter the circuit parameters; and a different backend can change compilation, connectivity, supported gates, queueing, or execution cost.

Revisit the estimate after changing any of these inputs:

  • Number, order, type, or range of features.
  • Padding, truncation, dimensionality reduction, or feature grouping.
  • Encoding layers, data re-uploading, entanglers, or ansatz depth.
  • Simulator versus real-hardware execution.
  • Shots, gradient method, optimizer, batch size, or training steps.
  • SDK version, compiler settings, backend connectivity, or error-mitigation procedure.

As a repeatable workflow, keep a small encoding report beside the experiment: dataset shape, preprocessing statistics, encoding type, qubit count, abstract depth, compiled depth, shots, estimated circuit evaluations, and software versions. Run the same smoke-test inputs after every change. Then use your circuit-testing and debugging workflow to verify state preparation and measurement behavior before spending time on model training. For broader platform decisions, compare the resulting resource profile across your selected SDK or cloud targets rather than comparing API convenience alone.

The most useful encoding is usually the one whose assumptions you can explain and reproduce. Start with the simplest representation that preserves the information needed by the task, estimate its full cost, and only add layers or a more compact state representation when an experiment gives you a clear reason to do so.

Related Topics

#quantum-machine-learning#data-encoding#feature-maps#pennylane#qiskit#qml-tutorial
S

SmartQbit Editorial Team

Quantum Computing Editors

Senior editor and content strategist. Writing about technology, design, and the future of digital media. Follow along for deep dives into the industry's moving parts.