Quantum Algorithms and Complexity

Chapter 12
Quantum Machine Learning and Data Analytics

Diploma in Quantum Computing
Quantum Algorithms and Complexity   •   Diploma

Quantum Machine Learning and Data Analytics

Introduction and context

Quantum machine learning (QML) studies learning methods that use quantum states, quantum circuits, or quantum-inspired linear algebra. It is not a single algorithmic technique. Rather, it is a family of approaches combining classical data analysis with quantum computation. In current practice, most QML systems are hybrid: a classical computer prepares data, selects parameters, evaluates a quantum circuit, and updates the parameters using a classical optimizer.

The central question is not simply whether a quantum circuit can be inserted into a machine-learning pipeline. The relevant question is whether the complete system—including data encoding, circuit execution, measurement, optimization, error mitigation, and classical post-processing—provides a reliable advantage for a defined task and resource budget.

QML is especially relevant to quantum algorithms and complexity because its performance depends on several costs:

  • the number of qubits and gates;
  • circuit depth and noise sensitivity;
  • the number of measurements, or shots;
  • the cost of loading classical data into quantum states;
  • classical optimization and memory costs; and
  • the statistical quality of the benchmark.

This chapter examines quantum kernels, quantum feature maps, variational quantum classifiers, selected linear-algebra-based methods, data-loading costs, trainability, benchmarking, dequantization, and responsible claims about AI advantage.

Learning objectives

By the end of this chapter, a student should be able to:

  1. Explain how quantum feature maps and quantum kernels represent data.
  2. Describe the operation of a variational quantum classifier and its training loop.
  3. Distinguish state-preparation, circuit, measurement, and classical computational costs.
  4. Explain the role of trainability, barren plateaus, noise, and shot uncertainty.
  5. Compare kernel methods, variational methods, and selected quantum linear-algebra approaches.
  6. Design a fair benchmark against strong classical baselines.
  7. Explain dequantization and identify exaggerated claims of quantum machine-learning advantage.
  8. Discuss privacy, fairness, reproducibility, and governance in QML applications.

1. The hybrid QML workflow

A typical supervised-learning problem contains examples (xi,yi), where xi is a feature vector and yi is a label or target. A classical model uses a parameterized function f_θ(xi), where θ denotes trainable parameters. In QML, the function may include a quantum circuit:

f_θ(x) = ⟨0| U†(x,θ) M U(x,θ) |0⟩

Here, U(x,θ) is a data-dependent and parameter-dependent unitary circuit, M is an observable measured on the circuit, and the expectation value is estimated from repeated executions. The output is generally a real number, not an exact value, because measurements are probabilistic.

A practical workflow is:

  1. Clean, normalize, and partition classical data.
  2. Select a feature subset or dimensionality-reduction method.
  3. Encode each example into a quantum state or circuit.
  4. Execute the circuit repeatedly and estimate outputs.
  5. Compute a loss or kernel matrix.
  6. Update classical parameters, if the method is variational.
  7. Validate on data not used for model selection.
  8. Compare the complete pipeline with classical alternatives.
Hybrid quantum machine learning workflow Classical dataclean / scale Encodingfeature map Quantum circuitmeasure shots Classical steploss / update Repeat until stopping criterion or budget is reached
Hybrid quantum machine learning workflow
Figure: Hybrid quantum machine learning workflow

Figure: A hybrid quantum machine-learning training loop.

2. Quantum feature maps and kernels

2.1 Feature maps

A feature map is a procedure that transforms a classical vector x into a quantum state:

|φ(x)⟩ = U_φ(x)|0⟩⊗n

The vector x may contain more features than available qubits; therefore, features commonly require selection, scaling, angle encoding, amplitude encoding, or repeated encoding across circuit layers.

In angle encoding, a feature is represented by a rotation angle, for example:

U_φ(x) = ⨂j=1n Ry(xj)

where Ry(xj) is a rotation around the y-axis and the angles must be expressed consistently with the gate convention. Angle encoding is comparatively straightforward but generally requires one or more qubits per simultaneously encoded feature.

In amplitude encoding, a normalized vector is represented as amplitudes:

|x⟩ = ∑j=0N-1 xj |j⟩, with ∑j=0N-1|xj|² = 1

A vector with N components can theoretically occupy log₂N qubits, but preparing an arbitrary state may require substantial circuit depth or specialized data-loading hardware. The qubit count alone therefore does not establish an efficient algorithm.

Feature-map design affects expressivity, trainability, noise sensitivity, and the geometry of the induced data representation. Entangling gates can create nonlinear relationships, but greater circuit complexity may also make optimization and implementation more difficult.

2.2 Quantum kernels

A kernel measures similarity in a transformed feature space. The ideal quantum kernel is often defined as the squared overlap:

K(x,z) = |⟨φ(x)|φ(z)⟩|²

It satisfies 0 ≤ K(x,z) ≤ 1 for normalized states. A kernel matrix for training examples is

Kij = K(xi,xj)

A valid kernel matrix is symmetric and positive semidefinite, subject to numerical and estimation errors. A classical support-vector machine may then use this matrix to find a separating boundary. The quantum device supplies similarities; the optimization and classification may remain classical.

One way to estimate K(x,z) is to prepare |φ(x)⟩ and |φ(z)⟩ in a circuit such as a compute-uncompute test. If the probability of observing the all-zero state is p0, then, for the appropriate circuit, p0 = |⟨φ(x)|φ(z)⟩|². With S independent shots, the estimator hat p0 has approximate standard deviation

√(p0(1-p0)/S)

This is a sampling uncertainty, not a guaranteed error bound for all sources of noise. Device error, state-preparation error, readout error, and drift must also be considered.

2.3 Kernel concentration

In high-dimensional quantum feature spaces, similarities may concentrate around nearly identical values. If most off-diagonal kernel entries are approximately equal, the kernel may offer little useful discrimination. This can occur when circuits are too expressive, too deep, or poorly matched to the data. Consequently, “larger Hilbert space” does not automatically mean “better learning representation.”

A useful practice is to inspect the empirical kernel matrix, its spectrum, class-conditional similarities, condition number, and performance under controlled classical kernel baselines.

3. Variational quantum classifiers

A variational quantum classifier (VQC) uses a parameterized circuit to produce a prediction. A common structure is

U(x,θ) = W(θ) U_φ(x)

where U_φ(x) encodes data and W(θ) contains trainable gates. A measured expectation may be converted into a binary prediction:

ŷ = sign(f_θ(x) − b)

where b is a threshold and f_θ(x) is the measured expectation. For labels yi ∈ {−1,+1}, a mean-squared loss is

L(θ) = (1/m) ∑i=1m (f_θ(xi) − yi)²

where m is the number of training examples. Other losses, such as logistic or hinge loss, may be used, but the loss must be appropriate for the prediction task.

The training loop estimates L(θ), obtains a gradient or gradient approximation, and updates parameters. The parameter-shift rule for a suitable gate parameter θj is

∂f_θ/∂θj = [fθj+π/2 − fθj−π/2]/2

This expression applies to gates with the required generator spectrum and to the corresponding expectation value. It requires additional circuit evaluations, and finite-shot estimates introduce statistical noise.

A VQC should not be described as automatically superior to a neural network. Its usefulness depends on the data structure, circuit architecture, hardware quality, optimizer, training budget, and baseline quality.

4. Trainability and complexity

4.1 Barren plateaus

A barren plateau is a region in parameter space where gradients become very small, often exponentially small in the number of qubits under particular random-circuit assumptions. A schematic statement is

Var(∂L/∂θj) → 0 as n increases

where n is the number of qubits. This is not a universal law for every circuit. It depends on architecture, initialization, cost-function locality, connectivity, ansatz design, and noise.

Small gradients are difficult because shot noise and hardware errors can dominate the optimization signal. Mitigation strategies include shallow problem-informed ansätze, layerwise training, local cost functions, informed initialization, parameter sharing, and careful measurement allocation. None is guaranteed to remove the problem.

4.2 Expressivity versus trainability

An ansatz with many layers can represent a broad family of states, but increased expressivity can produce difficult optimization landscapes, greater circuit depth, and stronger noise accumulation. An effective design seeks sufficient capacity for the task rather than maximal generality.

Important resource measures include:

ResourceMeaningTypical concern
QubitsNumber of quantum registersLimits representation and connectivity
DepthSequential gate layersNoise and compilation overhead
Two-qubit gatesEntangling operationsOften the dominant hardware error source
ShotsRepetitions per circuitStatistical cost of expectations
ParametersTrainable circuit controlsOptimization and overfitting
Data encodingsCircuit executions per exampleEnd-to-end runtime and cost

4.3 Measurement and estimation cost

Suppose an observable has outcomes in [−1,1]. For S independent shots, the standard error of the sample mean is approximately

SE ≈ σ/√S

where σ is the standard deviation of the outcome distribution and σ ≤ 1. This relation assumes independent samples and describes sampling error only. To reduce standard error by a factor of two, approximately four times as many shots are required.

A training run may require many circuit evaluations per iteration. If there are m examples, p parameters, and parameter-shift gradients, a simple full-batch gradient estimate can require on the order of 2mp shifted evaluations, in addition to forward evaluations. Actual counts depend on batching, shared measurements, commuting observables, analytic simulation, and optimizer choice.

5. Selected linear-algebra-based quantum learning methods

Quantum algorithms for linear algebra are often proposed for regression, classification, recommendation, or dimensionality reduction. A classical least-squares problem seeks

β̂ = argmin_β ||Xβ − y||²

where X is a feature matrix, y is a target vector, and β is a coefficient vector. Under full column rank, the solution is

β̂ = (XᵀX)-1Xᵀy

However, explicitly forming an inverse is not always numerically or computationally desirable. Regularized ridge regression instead solves

β̂_λ = (XᵀX + λI)-1Xᵀy

where λ > 0 controls regularization and I is the identity matrix. Quantum linear-system algorithms aim, under demanding assumptions, to prepare a quantum state related to the solution rather than output every coefficient individually.

The assumptions can include efficient state preparation, sparse or structured matrices, favorable condition number, fault-tolerant operations, and an output observable that can be estimated efficiently. If the full classical vector is required, readout may remove the apparent speedup. Therefore, a claimed complexity improvement must specify input access, precision, output format, condition number, sparsity, and success probability.

Quantum principal component analysis and quantum singular-value-processing approaches similarly operate on encoded states or block-encoded matrices. These are powerful theoretical frameworks, but their practical advantage is highly conditional. A diploma-level analysis should ask: What is the input model? What is returned? How many repetitions are required? What classical preprocessing is hidden?

6. Data-loading costs and the input-model problem

Data loading is one of the most important issues in QML. Classical data do not automatically exist as amplitudes or quantum states. Preparing a state from a vector may require a circuit whose cost depends on structure, precision, sparsity, and hardware assumptions.

A complete runtime model can be represented conceptually as

Ttotal = Tprepare + Tcircuit + Tmeasure + Tclassical

where the four terms represent state preparation, quantum execution, measurement and repetition, and classical computation. If the data are loaded separately for each example and each circuit evaluation, Tprepare may dominate.

A fair comparison should distinguish:

  • online cost, paid during each prediction or training iteration;
  • offline cost, paid once to build a data structure or compile a circuit;
  • amortized cost, the offline cost divided across many uses; and
  • output cost, the cost of extracting a classical answer.

Claims based on quantum random-access memory (qRAM) must state whether qRAM is assumed as an oracle, how it is built, and whether its access cost is included. An abstract oracle model can establish a theoretical result without demonstrating an engineering implementation.

7. Dequantization and responsible advantage claims

Dequantization refers to classical algorithms that reproduce or narrow a claimed quantum advantage under comparable assumptions. For example, if a quantum method assumes efficient access to normalized data states, a classical method may assume a comparable data-access model such as length-squared sampling. The point is not that every quantum algorithm has a classical substitute. The point is that a speedup must be evaluated against the strongest relevant classical model, not an artificially weak baseline.

A responsible advantage claim specifies:

  1. the task and data distribution;
  2. the input-access model;
  3. the output required;
  4. accuracy and confidence requirements;
  5. training and inference costs;
  6. hardware, simulation, and compilation assumptions;
  7. the classical baselines and hyperparameter budgets;
  8. statistical uncertainty and repeated trials; and
  9. whether the advantage is asymptotic, empirical, practical, or merely representational.

A small accuracy improvement on one carefully selected dataset is not evidence of general quantum advantage. Conversely, failure on noisy small hardware does not prove that all QML methods are ineffective. Conclusions should match the evidence.

8. Benchmarking QML systems

Benchmarking must evaluate the whole pipeline. Recommended practices include:

  • use train, validation, and held-out test sets;
  • prevent preprocessing leakage across partitions;
  • report class balance and relevant performance metrics;
  • tune classical and quantum models under comparable budgets;
  • include simple baselines such as logistic regression and nearest neighbours;
  • include strong nonlinear baselines such as support-vector machines, random forests, and appropriately sized neural networks;
  • report wall-clock time, circuit executions, shots, energy or monetary cost where available;
  • repeat experiments with multiple random seeds;
  • provide confidence intervals or variability estimates;
  • compare noisy hardware, error-mitigated results, and ideal simulation separately; and
  • publish circuits, preprocessing, versions, seeds, and stopping criteria.

For imbalanced classification, accuracy may be misleading. Precision, recall, F1 score, balanced accuracy, area under the receiver-operating-characteristic curve, and calibration should be considered according to the application. A benchmark should not optimize the test set through repeated informal experimentation.

9. Worked example: estimating a quantum-kernel similarity

Consider two normalized single-qubit states produced by angle encoding:

|φ(x)⟩ = Ry(x)|0⟩

For x = 0 and z = π/3, the overlap is

⟨φ(x)|φ(z)⟩ = cos((z−x)/2) = cos(π/6) = √3/2

Therefore,

K(x,z) = |√3/2|² = 3/4 = 0.75

If the kernel circuit is measured for S = 400 shots and the true all-zero probability is p = 0.75, the approximate sampling standard error is

√(0.75 × 0.25 / 400) ≈ 0.0217

Thus, repeated estimates will vary by roughly 0.022 standard-error units under the independent-shot model. This does not include hardware bias. The example illustrates why a kernel value should be treated as an estimate and why more shots improve precision slowly: quadrupling shots halves the standard error.

10. Illustrative case study: quantum-kernel screening for materials data

Background

A fictional materials laboratory wants to classify molecular descriptors into two categories: candidates likely to satisfy a target stability criterion and candidates unlikely to do so. The dataset contains thousands of classical descriptors, while the available quantum processor has limited qubits and noisy two-qubit gates.

Problem

A project team proposes a quantum kernel and reports higher test accuracy than a poorly tuned linear classifier. Management asks whether this demonstrates quantum advantage.

Analysis

The raw descriptor dimension exceeds the usable qubit count. The team therefore applies a feature-selection procedure using only the training partition and retains eight features. It scales each feature using training-set statistics. It compares an angle-encoded quantum kernel with radial-basis and polynomial classical kernels, logistic regression, a random forest, and a small neural network.

The team records kernel-construction time, number of shots, circuit depth, two-qubit-gate count, classical preprocessing time, and test performance. It also evaluates an ideal simulator, a noise model, and hardware data. Confidence intervals are obtained through repeated stratified splits, while the final test set is used only once.

Approach and solution

The quantum kernel is estimated from a compute-uncompute circuit. The project reports both the kernel matrix construction cost and the downstream support-vector-machine cost. It examines the kernel spectrum and discovers that a deeper feature map increases training-set separation but causes concentration and poorer hardware performance. A shallower circuit gives slightly lower training accuracy but more stable validation results.

Outcome

The quantum model is competitive with classical baselines on this small, selected dataset, but the evidence does not establish practical quantum advantage. State preparation, measurement repetitions, and hardware queue time dominate the end-to-end workflow. The appropriate conclusion is that the feature map is a promising experimental representation requiring further study, not that quantum computing has already delivered a general materials-discovery advantage.

Learning points

  1. The baseline determines the credibility of a comparison.
  2. Feature selection and preprocessing are part of the algorithm.
  3. Kernel quality must be assessed statistically and spectrally, not only by accuracy.
  4. The complete data-loading and measurement costs matter.
  5. Responsible conclusions distinguish competitiveness from advantage.

11. Ethical, governance, and professional considerations

QML does not remove ordinary AI risks. If training data encode historical discrimination, a quantum model can reproduce it. If measurements are noisy or nondeterministic, users need uncertainty information rather than unjustified confidence. Sensitive data may be exposed during classical preprocessing, cloud execution, logging, or vendor access.

Professional practice should include:

  • documented data provenance and lawful use;
  • privacy-preserving preprocessing where appropriate;
  • fairness evaluation across relevant groups;
  • access controls and encryption for data and credentials;
  • audit trails for circuits, software versions, and results;
  • human review in high-impact decisions;
  • clear communication of uncertainty and limitations; and
  • independent replication before operational deployment.

Quantum hardware access also raises sustainability questions. Repeated circuit execution, cooling infrastructure, simulation, and cloud resource consumption should be considered where environmental impact is material.

12. Contemporary directions and best practices

Current QML research explores error mitigation, symmetry-preserving circuits, quantum neural tangent perspectives, quantum generative models, kernel alignment, adaptive ansätze, error-corrected algorithms, and quantum-enhanced sampling. These areas remain active research topics; many practical claims are provisional.

Best practices for diploma-level projects are:

  1. Start with a clearly defined prediction or estimation task.
  2. Use a small, reproducible dataset and strong classical baselines.
  3. Make the encoding and resource assumptions explicit.
  4. Prefer shallow, interpretable circuits before increasing depth.
  5. Separate simulator, noisy-simulator, and hardware results.
  6. Report shots, circuit counts, depth, and wall-clock or cloud cost.
  7. Use validation data for model selection and protect the test set.
  8. Treat quantum advantage as a claim requiring evidence, not as a default property of quantum models.

Chapter Summary

Quantum machine learning combines classical data analytics with quantum state preparation, circuits, measurements, and classical optimization. Quantum feature maps create data-dependent states, while quantum kernels estimate similarities that can feed classical kernel methods. Variational quantum classifiers train parameterized circuits using measured predictions and classical optimizers.

The principal practical constraints are data loading, circuit depth, two-qubit errors, shot noise, optimization difficulty, and output extraction. Barren plateaus and kernel concentration illustrate that expressivity alone is not sufficient. Linear-algebra-based quantum methods may offer theoretical benefits under specific input, sparsity, condition-number, precision, and output assumptions.

Credible evaluation requires end-to-end accounting, strong classical baselines, careful data partitioning, repeated experiments, uncertainty reporting, and explicit resource models. Dequantization reminds researchers to compare equivalent access assumptions. Responsible QML claims distinguish theoretical speedup, empirical competitiveness, and practical advantage while addressing fairness, privacy, security, reproducibility, and environmental cost.

Key Terms

Quantum machine learning: The study of learning methods involving quantum states, circuits, or quantum-inspired computation.

Feature map: A transformation that encodes classical data into a quantum state or circuit.

Angle encoding: Encoding feature values as rotation angles of quantum gates.

Amplitude encoding: Representing a normalized classical vector in the amplitudes of a quantum state.

Quantum kernel: A similarity function estimated from overlaps between quantum-encoded data states.

Kernel matrix: A matrix whose entries contain pairwise similarities between examples.

Variational quantum classifier: A hybrid model using a parameterized quantum circuit for prediction.

Ansatz: A chosen parameterized circuit structure used to represent candidate quantum states or functions.

Observable: A quantum operator whose expectation value is estimated through measurement.

Shot: One execution and measurement of a quantum circuit.

Barren plateau: An optimization region in which gradients become extremely small.

Trainability: The practical ability to optimize a parameterized model.

Data-loading cost: The computational and physical resources required to encode classical data into a quantum system.

Input model: Assumptions describing how an algorithm receives its data.

Dequantization: A classical method that reproduces or narrows a claimed quantum advantage under comparable assumptions.

Condition number: A measure of sensitivity of a linear-system problem to perturbations.

Error mitigation: Techniques that reduce the effect of noise without fully correcting it.

Quantum advantage: A demonstrated benefit over relevant classical alternatives under stated conditions.

Kernel concentration: The tendency of many high-dimensional kernel similarities to become nearly indistinguishable.

Hybrid algorithm: An algorithm that alternates or combines quantum computation with classical computation.

Review Questions

Short Answer Questions

  1. What is the purpose of a quantum feature map?
  2. Why is a quantum-kernel value estimated statistically on hardware?
  3. Define a barren plateau.
  4. Why can amplitude encoding have a high practical cost despite using few qubits?
  5. Name two costs that must be included in an end-to-end QML benchmark.

Long Answer Questions

  1. Explain the construction and use of a quantum kernel, including the role of the kernel matrix and measurement shots.
  2. Describe the training loop of a variational quantum classifier and discuss the parameter-shift rule.
  3. Compare angle encoding and amplitude encoding in terms of qubit requirements, preparation cost, and practical suitability.
  4. Explain why a theoretical quantum linear-algebra speedup may disappear when input and output costs are included.
  5. Develop a benchmarking protocol for comparing a quantum classifier with classical models.

Analytical / Application Questions

  1. A project reports a quantum model that beats logistic regression but not a tuned support-vector machine or random forest. Assess whether the result supports a claim of quantum advantage.
  2. A kernel estimate has true probability p = 0.60 and is measured with S = 900 independent shots. Calculate the approximate sampling standard error using √(p(1−p)/S) and explain what the result excludes.
  3. Design a small QML experiment for an imbalanced classification dataset. Specify preprocessing, encoding, baselines, metrics, resource measurements, and safeguards against data leakage.

Multiple Choice Questions with Answers

Question 1

What does a quantum feature map primarily do?

A. It converts a quantum measurement into a classical label without measurement noise.

B. It encodes classical data into a quantum state or data-dependent circuit.

C. It guarantees that a classifier has a lower computational complexity.

D. It replaces the need for a classical optimizer.

Correct Answer: B. It encodes classical data into a quantum state or data-dependent circuit.

Question 2

For normalized states, which expression defines the quantum kernel used in this chapter?

A. K(x,z) = |⟨φ(x)|φ(z)⟩|²

B. K(x,z) = ⟨φ(x)|φ(z)⟩² without taking the modulus

C. K(x,z) = |φ(x)⟩ + |φ(z)⟩

D. K(x,z) = 1 − ⟨φ(x)|φ(z)⟩ for all states

Correct Answer: A. K(x,z) = |⟨φ(x)|φ(z)⟩|²

Question 3

If the number of independent shots is increased by a factor of four, the approximate sampling standard error is:

A. Doubled

B. Unchanged

C. Halved

D. Reduced to one-quarter

Correct Answer: C. Halved

Question 4

Which statement about amplitude encoding is correct?

A. It always requires one qubit per classical feature.

B. It can represent N components using log₂N qubits in principle, but state preparation may be costly.

C. It avoids the need to normalize the input vector.

D. It guarantees efficient data loading on current hardware.

Correct Answer: B. It can represent N components using log₂N qubits in principle, but state preparation may be costly.

Question 5

What is a barren plateau?

A. A region where all circuit outputs are exactly zero.

B. A region where gradients can become extremely small and optimization becomes difficult.

C. A hardware layout with no two-qubit gates.

D. A classical method for removing outliers.

Correct Answer: B. A region where gradients can become extremely small and optimization becomes difficult.

Question 6

Which quantity is part of the complete QML runtime model described in the chapter?

A. Only the number of qubits

B. Only the final classification accuracy

C. State preparation, circuit execution, measurement, and classical computation

D. Only the number of trainable parameters

Correct Answer: C. State preparation, circuit execution, measurement, and classical computation

Question 7

For p = 0.75 and S = 400, the approximate sampling standard error √(p(1−p)/S) is closest to:

A. 0.0022

B. 0.0217

C. 0.217

D. 2.17

Correct Answer: B. 0.0217

Question 8

What is dequantization intended to examine?

A. Whether a quantum computer can operate without measurements

B. Whether comparable classical methods can reproduce or narrow a claimed quantum advantage under similar assumptions

C. Whether quantum states can be stored as ordinary text files

D. Whether all classical machine-learning models are inefficient

Correct Answer: B. Whether comparable classical methods can reproduce or narrow a claimed quantum advantage under similar assumptions

Question 9

Which practice strengthens a QML benchmark?

A. Comparing only with an untuned linear model

B. Using the test set repeatedly to select hyperparameters

C. Reporting strong classical baselines, resource costs, uncertainty, and data partitions

D. Reporting ideal simulation results while omitting hardware noise

Correct Answer: C. Reporting strong classical baselines, resource costs, uncertainty, and data partitions

Question 10

In ridge regression, what does the parameter λ control?

A. The number of quantum shots

B. The regularization strength

C. The number of labels

D. The measurement basis only

Correct Answer: B. The regularization strength

Quantum Algorithms and Complexity
Chapter 12 of 14