Quantum Machine Learning Data Encoding: A Practical Guide to Angle, Amplitude and Basis Embedding
quantum machine learningquantum data encodingPennyLaneQiskitvariational circuits

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

SSmart Qubit Labs Editorial Team
2026-11-12
8 min read

Compare basis, angle and amplitude encoding for quantum machine learning, with PennyLane and Qiskit workflows and a reusable test checklist.

Choosing a data-encoding method is one of the first design decisions in a quantum machine-learning experiment. This guide compares basis, angle and amplitude embedding, explains their trade-offs, and provides practical PennyLane and Qiskit workflows you can reuse when changing datasets, circuits or hardware targets.

Overview

Quantum data encoding, sometimes called quantum feature mapping, converts classical observations into the quantum state of one or more qubits. The encoding is not a minor implementation detail: it affects the number of qubits required, circuit depth, state preparation cost, feature interpretability and how fairly you can compare a quantum model with a classical baseline.

There is no universally best encoding. The right choice depends on the shape of the data, the available simulator or quantum processor, the model architecture and the question your experiment is intended to answer. For many small, structured datasets, angle encoding is a practical starting point. Basis encoding can be useful for binary or categorical information. Amplitude encoding is attractive when qubit efficiency matters, but its state-preparation overhead and normalization requirements need careful measurement.

Reference comparison

MethodTypical qubit requirementCircuit depth and loadingNormalizationInterpretabilitySuitable data scale
Basis embeddingOften one qubit per binary featureSimple computational-basis preparation; depth is usually modestFeatures must be represented as binary values or mapped to bit stringsHigh for binary states; each qubit has a direct bit interpretationSmall binary, categorical or thresholded datasets
Angle embeddingCommonly one qubit per feature per layerRotation gates are straightforward; depth grows with repeated layers and feature re-uploadingScale features to a suitable rotation rangeRelatively high because features control individual rotationsSmall to medium feature vectors after reduction or selection
Amplitude embeddingApproximately log2 of the number of amplitudes, with padding where neededState preparation can be considerably more involved than the variational circuit itselfInput vector must be normalised, or normalisation must be handled explicitlyLower at the individual-qubit level because features are distributed across amplitudesCompact vectors where qubit reduction is more important than simple loading

These are design patterns rather than guarantees. Actual depth depends on the SDK, decomposition, connectivity, compilation settings and hardware. A quantum circuit simulator may also hide costs that become important when the circuit is transpiled for a device.

Before selecting an embedding, define a classical reference model and a data budget. Our guide to benchmarking quantum algorithms against classical methods provides a useful framework for keeping the comparison honest. For a broader explanation of the three methods, see Quantum Data Encoding Methods Compared.

Checklist by scenario

Choose basis embedding when the data is naturally binary

  • Use it when each observation can be represented as 0 or 1 without discarding important information.
  • Document any thresholding, binarisation or categorical-to-binary conversion before the encoding step.
  • Check whether the number of features is small enough for the available qubits.
  • Test multiple thresholds if the binary conversion is part of the modelling decision.

Basis embedding is easy to explain: a feature determines the computational state of a qubit. However, converting continuous values into bits can remove ordering and magnitude information. If that information matters, angle encoding may preserve it more directly.

Choose angle embedding for a clear first experiment

  • Scale each continuous feature to a known interval, such as a range appropriate for the rotation gates in your circuit.
  • Start with one rotation per feature and one encoding layer.
  • Use feature selection or classical dimensionality reduction if the feature count exceeds the available qubits.
  • Only add data re-uploading after establishing a baseline with a single encoding layer.

Angle encoding maps numerical values to rotation angles. It is often a practical option for a PennyLane tutorial or a first Qiskit experiment because the relationship between the input features and gates is easy to inspect. The trade-off is that the qubit requirement usually grows with the number of features, unless features are reused across layers.

Choose amplitude embedding when qubit count is the main constraint

  • Decide the target state dimension before preparing the data. A vector with a non-power-of-two length normally needs padding.
  • Normalise the vector using a reproducible preprocessing step and record the method.
  • Measure state-preparation depth separately from the variational circuit.
  • Check whether the selected simulator or hardware workflow supports the required preparation method.

Amplitude embedding stores values in the probability amplitudes of a quantum state. In principle, this can represent a vector using fewer qubits than one-feature-per-qubit methods. It does not mean that loading the data is free. State preparation may require a substantial circuit, and the useful comparison is the full workflow: preprocessing, encoding, trainable circuit, measurement and classical optimisation.

Implement the same experiment in PennyLane

A minimal PennyLane workflow can expose the difference between embeddings without changing the rest of the model. The following example assumes that features has already been scaled and that the chosen device supports the operations used by the embedding.

import pennylane as qml
from pennylane import numpy as np

n_qubits = 3
dev = qml.device('default.qubit', wires=n_qubits)

@qml.qnode(dev)
def angle_circuit(features, weights):
    qml.AngleEmbedding(features, wires=range(n_qubits), rotation='Y')
    qml.StronglyEntanglingLayers(weights, wires=range(n_qubits))
    return qml.expval(qml.PauliZ(0))

@qml.qnode(dev)
def amplitude_circuit(features, weights):
    qml.AmplitudeEmbedding(features, wires=range(n_qubits), normalize=True, pad_with=0.0)
    qml.StronglyEntanglingLayers(weights, wires=range(n_qubits))
    return qml.expval(qml.PauliZ(0))

For basis encoding, convert the input to a bit string and use the SDK’s basis-embedding operation or explicit Pauli-X gates. Keep the trainable layers, optimiser, random seed and measurement definition identical across variants. That isolates the encoding as the principal experimental variable.

Implement the same comparison in Qiskit

In Qiskit, construct separate circuits that share the same register size and variational layer. The exact execution path can vary by installed Qiskit version and backend, so treat circuit construction and execution as separate stages.

from qiskit import QuantumCircuit
from qiskit.circuit import ParameterVector

n_qubits = 3
angles = ParameterVector('x', length=n_qubits)
weights = ParameterVector('w', length=n_qubits)

angle = QuantumCircuit(n_qubits)
for i in range(n_qubits):
    angle.ry(angles[i], i)
for i in range(n_qubits):
    angle.rz(weights[i], i)

basis = QuantumCircuit(n_qubits)
bit_values = [1, 0, 1]
for i, value in enumerate(bit_values):
    if value == 1:
        basis.x(i)
for i in range(n_qubits):
    basis.rz(weights[i], i)

For amplitude encoding, prepare a normalised vector and use a state-preparation instruction supported by the selected Qiskit workflow. Record whether the preparation is represented as an abstract instruction or decomposed into native gates. Those two views can have very different depth and execution implications.

If you are deciding between SDKs as well as encodings, the Qiskit, PennyLane and Cirq comparison can help separate modelling requirements from tooling preferences.

What to double-check

Preprocessing checklist

  • Split before fitting: fit scaling, imputation and dimensionality-reduction steps on the training partition only.
  • Record feature order: the same column order must be used during training, validation and inference.
  • Handle missing values: do not allow an embedding function to silently convert missing data into a meaningful quantum state.
  • Choose scaling deliberately: angle encoding can be sensitive to the selected range, while amplitude encoding requires a valid state vector.
  • Preserve labels separately: labels should not be included in the encoded feature vector.
  • Track padding: for amplitude encoding, record which entries were added and ensure padding is applied consistently.

Experiment-design template

For each encoding, write down the following before running the experiment:

  1. Dataset: name, task, sample count, feature count and class balance.
  2. Preprocessing: imputation, scaling, feature selection, dimensionality reduction and padding.
  3. Encoding: basis, angle or amplitude; qubit count; number of encoding layers; and any feature re-uploading.
  4. Model: trainable gate layout, entanglement pattern, parameter count and measurement.
  5. Training: optimiser, stopping rule, initialisation method, number of repetitions and random seeds.
  6. Baselines: at least one simple classical model and, where practical, a model with a comparable parameter or input budget.
  7. Results: predictive metric, training behaviour, circuit depth, two-qubit gate count where available, runtime and failure cases.

This structure avoids presenting a difference in accuracy as evidence of quantum advantage by itself. A model can appear better because it received different preprocessing, more parameters, a more favourable split or a different optimisation budget. For an enterprise or research project, also document reproducibility and vendor dependencies. The quantum technology vendor due diligence checklist is relevant when a prototype depends on a hosted platform.

Common mistakes

  • Choosing amplitude encoding solely because it uses fewer qubits: fewer qubits do not automatically mean lower total cost. Include state preparation in the resource assessment.
  • Skipping a classical baseline: quantum circuit results are difficult to interpret without a reference model trained on the same split.
  • Overloading a small device: forcing dozens of features into a small circuit through repeated re-uploading can make the model deeper and harder to train.
  • Ignoring data leakage: normalising or selecting features before splitting the dataset can inflate evaluation results.
  • Comparing unequal circuits: changing the encoding, ansatz, parameter count and optimiser simultaneously makes the conclusion ambiguous.
  • Treating simulator results as hardware results: noise, connectivity, transpilation and sampling can change both performance and cost.
  • Assuming more layers are better: deeper circuits increase expressive capacity but can also increase optimisation difficulty and execution overhead.
  • Failing to state the encoding convention: document qubit ordering, feature ordering, rotation axis, scaling range and amplitude padding.

These issues are especially important in hybrid quantum-classical computing, where a classical optimiser repeatedly calls a quantum circuit. A useful model is not only accurate; it must also be measurable, reproducible and practical to run.

When to revisit

Revisit the encoding decision whenever the underlying inputs or workflow change. A seasonal planning cycle is a useful prompt for reviewing datasets, feature definitions, validation splits and resource assumptions. Revisit sooner if the feature count changes, a new data source is added, labels become imbalanced, or preprocessing is moved into a production pipeline.

Also review the experiment after a major PennyLane or Qiskit release, a backend change, a new transpilation workflow or a move from simulation to hardware. Embedding capabilities, supported operations and execution interfaces can change, while the scientific comparison should remain stable. Re-run the same small reference dataset before migrating a larger experiment.

Use this practical sequence:

  1. Freeze a small, versioned dataset and preprocessing configuration.
  2. Run basis, angle and amplitude variants only where each is valid for the data.
  3. Keep the ansatz, training budget, evaluation split and seeds as consistent as possible.
  4. Record qubit count, circuit depth, state-preparation cost and execution conditions.
  5. Compare against classical baselines before interpreting any quantum result.
  6. Update the experiment log and document why the selected encoding remains appropriate.

When the experiment becomes part of a wider business case, connect the technical results to a defined operational metric rather than a general claim about quantum advantage. Our guide to building a quantum computing business case offers a structured way to do that. For a complete first workflow, see the PennyLane hybrid model tutorial.

Related Topics

#quantum machine learning#quantum data encoding#PennyLane#Qiskit#variational circuits
S

Smart Qubit Labs Editorial Team

Quantum Computing Editor

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.