A variational quantum classifier can look impressive in a notebook while saying little about whether the quantum circuit improved the machine-learning task. This guide presents a reproducible quantum machine learning workflow: prepare and scale the data, compare encoding strategies, design a controlled variational circuit, separate training from evaluation, test against classical baselines, and record the settings needed to explain each result.
Overview
A variational quantum classifier (VQC) is a hybrid model. A classical computer prepares feature values, selects trainable parameters, and runs an optimizer. A quantum circuit encodes the input, applies parameterized gates, and produces measurements. Those measurements become a prediction, a loss value, or an input to a classical post-processing step.
The basic loop is:
- Transform each example into a suitable numerical feature vector.
- Encode some or all of those features into qubit rotations or another circuit representation.
- Apply trainable variational layers, often with entangling gates.
- Measure one or more observables to obtain a model output.
- Calculate a loss and update the circuit parameters with a classical optimizer.
For binary classification, the measured expectation value may be mapped to a score between two classes. The exact mapping is less important than defining it before testing and using the same rule for every model variant.
A VQC is not automatically superior to a classical classifier. Results can be dominated by data preprocessing, feature selection, optimizer behavior, circuit depth, simulator settings, or random initialization. The purpose of a sound experiment is therefore not to prove that a quantum circuit wins in every setting. It is to determine whether a particular encoding and circuit provide a useful result under clearly stated conditions.
Before starting, decide what success means. It might be validation accuracy above a chosen threshold, a lower validation loss, stable performance across random seeds, or a practical learning exercise. A small, well-controlled experiment is more informative than a large experiment with changing assumptions.
How to compare options
Compare quantum classifiers as complete workflows rather than as isolated circuits. At minimum, keep the dataset split, preprocessing method, metric, training budget, and evaluation procedure consistent.
1. Fix the data protocol
Use separate training, validation, and test sets. The training set updates parameters. The validation set helps choose circuit depth, learning rate, encoding, and stopping criteria. The test set should remain untouched until the final comparison. If the dataset is small, document the split seed and consider repeating the experiment with several seeds.
Fit scaling parameters on the training data only. Applying a scaler to the complete dataset before splitting can leak information from the validation or test sets into training. Common choices include standardization and min-max scaling, but the right choice depends on the feature distribution and the circuit's angle range.
2. Compare encodings under a fixed budget
Data encoding determines how classical features become quantum states. Angle encoding places feature values into rotation angles and is often a practical starting point because it is easy to inspect. Amplitude encoding represents a vector in the amplitudes of a quantum state, but it may require state preparation and normalization choices that complicate the comparison. Basis-style encodings are useful for discrete information but may not suit continuous data without a separate transformation.
Do not compare encodings while also changing the number of qubits, circuit depth, optimizer, and training steps. If several variables change at once, a better result cannot be attributed to the encoding.
3. Establish classical baselines
Train at least one simple classical model on the same processed features. Logistic regression is a useful reference for linearly separable data; a small tree-based or kernel model can test whether nonlinear structure explains the result. The baseline does not need to be the strongest model available. It needs to be clear, reproducible, and appropriate for the dataset.
A quantum model that matches a baseline can still be valuable as a learning exercise or as a hardware-oriented prototype. It should not be described as an improvement unless the comparison supports that conclusion.
4. Report more than one score
Accuracy can conceal class imbalance. Record the confusion matrix and choose additional metrics such as precision, recall, F1 score, or a threshold-independent metric when appropriate. Report training and validation behavior, not just the best training score. A model that fits the training data while validation performance stagnates may be overfitting.
Feature-by-feature breakdown
Data scaling and feature selection
Qubits do not receive arbitrary tabular features directly. Features must be converted into values compatible with the chosen circuit. Start with a small feature subset so that the experiment remains interpretable. When the number of features exceeds the available qubits, compare explicit feature selection, dimensionality reduction, and repeated or structured encoding. Each option changes the model and should be logged.
Scaling also affects optimization. Very large or inconsistent rotation angles can make the circuit difficult to train or create periodic behavior that obscures the relationship between inputs and predictions. Record the scaling range, transformation, selected columns, and handling of missing values.
Feature maps and quantum data encoding
A feature map is the part of the circuit that injects an input into a quantum state. A shallow map with single-qubit rotations provides a transparent baseline. Additional data-dependent entangling operations may represent interactions between features, but they also increase circuit complexity and can make results harder to diagnose.
Use an ablation plan: compare no entangling data layer, a simple entangling layer, and any more complex alternative while holding the variational portion constant. This reveals whether the added structure contributes measurable value.
Variational circuit design
The variational circuit contains trainable parameters. A common pattern alternates single-qubit rotations with an entangling pattern. Increasing depth gives the model more parameters and expressive capacity, but it also increases gate count, execution time, and exposure to noise on hardware. A deeper circuit is not automatically a better classifier.
Track qubit count, circuit depth, trainable parameter count, gate types, entangling connectivity, and measurement operators. These details make it possible to reproduce an experiment and connect classifier results to resource requirements. For a deeper treatment of these measurements, see Quantum Circuit Resource Estimation.
Optimizers and initialization
Optimizer choice can change the conclusion. Gradient-based methods may work well in a differentiable simulator, while hardware execution introduces sampling variation and measurement cost. Gradient-free methods can be useful when gradients are noisy or unavailable, but they may require many circuit evaluations.
Initialize parameters with a documented rule and repeat the run with more than one random seed when possible. Save the loss at every step, the final parameters, the stopping condition, and the number of circuit evaluations. A single favorable run is weak evidence.
Shots, simulators, and hardware
An ideal state-vector simulator can return exact expectation values within numerical precision. A shot-based simulator estimates those values from repeated measurements, introducing sampling noise. Hardware adds device noise, queue or execution constraints, connectivity restrictions, and compilation effects. These are different experimental conditions and should not be presented as interchangeable.
Begin with an ideal or high-control simulation to verify the data pipeline and circuit logic. Add finite shots to study measurement variability. Only then compare a hardware execution or a noisy simulation, keeping the circuit and evaluation protocol as consistent as practical. If mitigation is used, report the unmitigated result as well as the adjusted result; otherwise the reader cannot assess its effect. The quantum error mitigation benchmarking workflow provides a useful framework for that comparison.
Evaluation and reproducibility
Create an experiment table with one row per run or configuration. Useful columns include dataset version, feature columns, split seed, scaler, qubit count, encoding, variational depth, entangling pattern, optimizer, learning rate, training steps, shot count, backend type, random seed, training loss, validation loss, test metrics, and runtime or circuit-evaluation count.
| Comparison | Keep constant | Change | Question |
|---|---|---|---|
| Encoding study | Split, circuit depth, optimizer, budget | Encoding method | Does representation affect validation performance? |
| Depth study | Encoding, split, optimizer, shots | Variational layers | Does added capacity justify added cost? |
| Noise study | Data and circuit | Shots, noise model, backend | How stable is the result outside ideal simulation? |
| Baseline study | Processed features and split | Model family | Does the VQC outperform or complement a classical approach? |
Frameworks such as PennyLane and Qiskit Machine Learning can connect circuit definitions with classical optimization, but interfaces and supported integrations change over time. Keep model logic separate from data preparation and evaluation so that a backend or library update does not silently alter the experiment.
Best fit by scenario
For a first quantum machine learning tutorial
Choose a small binary dataset, two to four carefully selected features, angle encoding, a shallow variational circuit, and an ideal simulator. The goal is to understand the full training loop. Plot loss and validation metrics, and verify that labels, predictions, and measurement interpretation are correct before adding complexity.
For comparing quantum data encoding
Use the same reduced dataset and circuit budget for every encoding. Document any normalization or padding required by the representation. Include a classical baseline and repeat the experiment across seeds. Focus on stability and evaluation cost, not only the highest score.
For testing hardware readiness
Reduce circuit depth and measurement requirements before submitting jobs. Estimate qubit count, depth, gates, and execution cost using a resource checklist. Run the circuit with finite shots, inspect variation between runs, and compare results with an ideal reference. A hardware experiment may be useful even when its accuracy is lower, because it exposes constraints hidden by ideal simulation.
Readers exploring broader algorithm choices can compare this workflow with the VQE workflow or the QAOA Max-Cut tutorial. Those algorithms solve different problem types, but they share important concerns: parameter initialization, optimization, circuit depth, measurement budget, and fair evaluation.
For a production-oriented investigation
Treat the VQC as a candidate model, not a replacement for an established pipeline. Define the business metric, latency or execution budget, data governance requirements, and acceptable variance. Compare against a strong classical baseline and test whether the circuit remains useful when data volume, feature distributions, and backend conditions change.
When to revisit
Revisit this workflow whenever a new dataset, encoding, simulator, optimizer, or execution backend enters the comparison. A change in any of these inputs can alter the result enough to invalidate an old table. Update the experiment record when circuit depth changes, features are added, the shot budget changes, or a noise model is introduced.
Framework integrations should also be checked after significant releases of PennyLane, Qiskit Machine Learning, or related quantum SDKs. Confirm that device names, differentiation methods, optimizer interfaces, dataset APIs, and hardware execution behavior still match the documented experiment. Avoid silently rerunning old code against a new default.
For a practical refresh, follow this checklist:
- Freeze the dataset version, preprocessing rules, and split seeds.
- Rerun the classical baseline before evaluating the quantum variants.
- Repeat the best configurations with multiple random seeds.
- Record qubits, depth, gates, shots, backend, optimizer, and circuit evaluations.
- Compare ideal, shot-based, and hardware or noisy results separately.
- Update the table with validation and test metrics, uncertainty or run-to-run variation, and known limitations.
- State clearly whether the result demonstrates a learning workflow, a resource tradeoff, or evidence of task-level improvement.
The most credible quantum classifier experiment is not the one with the most elaborate circuit. It is the one where another developer can identify what changed, reproduce the comparison, and understand whether the result came from quantum circuit design, data preparation, or an ordinary modeling effect.