Quantum Machine Learning and AnalyticsIntroductionQuantum machine learning (QML) combines quantum information processing with statistical learning. Its central question is not whether every machine-learning task becomes faster on a quantum computer, but whether particular data representations, models, or optimization procedures can use quantum effects—such as superposition, interference, and entanglement—to improve prediction, sampling, representation, or search. For diploma-level practitioners, QML is best understood as a developing technology stack rather than a replacement for classical machine learning. A realistic workflow usually contains classical data preparation, quantum circuit execution, classical parameter optimization, and classical evaluation. Current devices are noisy and small, so useful experimentation normally involves hybrid quantum–classical algorithms and careful comparison with strong classical baselines. Learning objectivesBy the end of this chapter, students should be able to: - explain quantum feature maps and quantum kernels;
- describe variational quantum classifiers and their training loop;
- distinguish quantum approaches to clustering, generative modelling, and optimization;
- assess data-encoding cost, trainability, noise, and interpretability;
- design a fair experiment for evaluating claims of quantum advantage;
- identify practical, ethical, and governance issues in quantum analytics.
1. From classical data to quantum modelsA classical observation is commonly represented as a vector x = (x1, x2, …, xd) ∈ ℝd. A quantum model must convert this vector into a quantum state. This conversion is called data encoding or state preparation. A quantum circuit then transforms the state, measurements produce classical outcomes, and a classical procedure uses those outcomes for prediction or optimization. A generic hybrid model is ŷ = f_θ(x) = g(⟨ψ(x)| U(θ)† M U(θ) |ψ(x)⟩) Here, |ψ(x)⟩ is the encoded input state, U(θ) is a trainable unitary circuit with parameters θ, M is a measurement observable, ⟨ψ|U†MU|ψ⟩ is the expected measurement value, and g maps that value to a prediction. The expression assumes ideal state preparation and measurement; real hardware estimates the expectation from a finite number of circuit repetitions, called shots. For a binary classifier, a probability can be obtained from a measured expectation value: p(y = 1|x) = (1 + ⟨M⟩x) / 2 when the observable has eigenvalues −1 and +1. The result lies between 0 and 1. Other observables or calibration procedures require a different mapping. The main design choices are: - Encoding: how classical features become gates or amplitudes.
- Feature map: how data-dependent quantum transformations create a representation.
- Ansatz: the parameterized circuit used to learn a decision function.
- Measurement: which observables are measured.
- Loss and optimizer: how predictions are compared with labels and parameters updated.
- Benchmark: the classical and quantum alternatives used for evaluation.
2. Quantum feature mapsA quantum feature map is a parameterized unitary U_φ(x) that maps a reference state, usually |0⟩⊗n, to a data-dependent state: |φ(x)⟩ = U_φ(x)|0⟩⊗n The number of qubits is n. The feature map may encode features as rotation angles, computational-basis amplitudes, or phases. It may also include entangling gates so that relationships among features affect the resulting state. 2.1 Angle encodingIn angle encoding, feature values control one-qubit rotations, for example Ry(xi). With one feature per qubit, d features require approximately d qubits, although features may be re-uploaded in multiple circuit layers. Values usually need scaling to a suitable interval such as [−π, π]. Scaling is not merely cosmetic: very large or poorly normalized angles can make optimization unstable or cause different inputs to produce similar states. 2.2 Amplitude encodingAmplitude encoding represents a normalized vector as amplitudes: |x⟩ = ∑i=02n−1 xi |i⟩, ∑i |xi|² = 1 The vector has at most 2n real components for n qubits, suggesting high representational density. However, preparing an arbitrary amplitude-encoded state can be expensive and may require substantial circuit depth. The preparation cost and access model must therefore be included in any speedup claim. 2.3 Basis and feature re-uploadingBasis encoding stores discrete values in computational-basis states and is useful when inputs are already binary or categorical after preprocessing. Feature re-uploading repeatedly inserts data-dependent gates into a shallow circuit. It can increase expressive power without allocating one qubit to every feature, but it also increases depth and may amplify noise. 2.4 Entangling feature mapsEntangling gates allow the representation to contain non-separable relationships. A circuit might apply single-qubit rotations followed by controlled-Z gates. Entanglement is not automatically beneficial: a problem must possess structure that the chosen entangling pattern can represent, and the resulting circuit must remain trainable on available hardware. 3. Quantum kernelsA kernel measures similarity in an implicit feature space. In a quantum kernel method, two inputs are mapped to quantum states and their overlap is used as a similarity measure: K(x, z) = |⟨φ(x)|φ(z)⟩|² For normalized states, 0 ≤ K(x,z) ≤ 1. The squared overlap is real and non-negative and is commonly estimated using a controlled test, an inverse feature-map circuit, or related measurement procedure. The exact circuit affects sampling cost and noise sensitivity. A kernel matrix for m examples is Kij = K(xi, xj), i,j = 1,…,m For standard kernel methods, this matrix should be symmetric and positive semidefinite, at least up to estimation error. A support-vector machine may solve a regularized optimization involving this matrix. A common soft-margin objective is: minw,b,ξ 1/2 ||w||² + C∑i=1m ξi subject to yi(w·φ(xi)+b) ≥ 1−ξi, ξi ≥ 0 Here, yi ∈ {−1,+1} are labels, w and b define the separating hyperplane in feature space, ξi are slack variables, and C > 0 controls the trade-off between margin size and training errors. The displayed formulation describes a classical support-vector machine after a kernel has supplied inner products; it does not imply that the optimization itself is quantum. Quantum kernels are attractive when the feature map creates a similarity structure that is difficult or useful for the task. They are less attractive when constructing the kernel matrix requires many noisy circuit evaluations, when the matrix is nearly constant, or when a classical kernel performs equally well at lower cost. 4. Variational quantum classifiersA variational quantum classifier (VQC) uses a parameterized circuit to produce a prediction. A typical circuit has the form |ψ(x,θ)⟩ = U_θ U_φ(x)|0⟩⊗n The model measures one or more observables and minimizes a loss. For binary cross-entropy: L(θ) = −∑i=1m [yi log p_θ(xi) + (1−yi)log(1−p_θ(xi))] where yi ∈ {0,1}, p_θ(xi) is the predicted probability, and terms with probability exactly 0 or 1 are handled numerically using a small clipping constant. If class frequencies are unequal, weighted losses or balanced evaluation metrics may be appropriate. A training iteration is: - encode a batch of data;
- execute the parameterized circuit;
- estimate observables from shots;
- calculate the loss;
- update θ using a classical optimizer;
- repeat on validation data and stop according to a pre-specified rule.
Gradients may be obtained by finite differences, parameter-shift rules, automatic differentiation supported by a simulator, or gradient-free methods. For a suitable rotation parameter θ, a parameter-shift estimate often has the form ∂f(θ)/∂θ = [f(θ + π/2) − f(θ − π/2)] / 2 This relation applies to gates with the appropriate generator normalization, not to every arbitrary parameterized operation. Each derivative requires additional circuit evaluations, so shot noise and execution time matter. TrainabilityA circuit is trainable when its parameters can be changed to reduce the loss efficiently. A major difficulty is the barren plateau, in which the variance of gradients decreases rapidly with system size or circuit depth. Gradients then become difficult to distinguish from measurement noise. Risk factors include highly expressive random circuits, excessive depth, global cost functions, and poor initialization. Practical responses include shallow problem-informed ansätze, local cost functions, layer-wise training, parameter initialization near known useful circuits, feature normalization, and noise-aware optimization. These are mitigation strategies, not guarantees of successful training. 5. Quantum clustering and dimensional analysisClustering is unsupervised: labels are unavailable, and the objective is to identify groups or structure. A quantum approach may use a quantum kernel as a similarity matrix, quantum distance estimation, amplitude-based sampling, or a variational assignment circuit. In practice, many proposals are hybrid: quantum circuits calculate similarities while classical algorithms perform k-means, spectral clustering, or evaluation. Classical k-means minimizes within-cluster squared distance: J = ∑j=1k ∑xi ∈ Cj ||xi − μj||² where Cj is cluster j, μj is its centroid, and k is the chosen number of clusters. A quantum kernel can replace the ordinary Euclidean similarity with a feature-space similarity, but cluster quality must still be assessed using domain criteria, silhouette scores, stability, or external labels where available. A quantum representation can reveal separability that is not obvious in the original coordinates. It can also obscure interpretation: a cluster formed by quantum-state overlap may be difficult to explain to a domain specialist. Therefore, visualization, feature attribution, and sensitivity analysis remain important. 6. Quantum generative modelsGenerative models learn a distribution and produce new samples. A parameterized quantum circuit can generate a distribution over bit strings by measuring its output state: p_θ(z) = |⟨z|U(θ)|0⟩⊗n|² Here, z is an n-bit measurement outcome. A quantum generative adversarial network uses a quantum generator and a discriminator, which may be classical or quantum. A quantum circuit Born machine directly trains a circuit so that its measurement distribution resembles the target distribution. Training may use maximum likelihood, divergence measures, or adversarial objectives. For a target distribution q and model distribution p, the Kullback–Leibler divergence is DKL(q||p) = ∑z q(z) log[q(z)/p(z)] This quantity is non-negative when q and p are valid distributions and q is zero wherever p is zero; it is not symmetric. Estimating it requires adequate samples and careful treatment of zero probabilities. Generative evaluation should also consider sample quality, diversity, calibration, and downstream usefulness—not only a single numerical score. Applications include synthetic discrete data, probabilistic modelling, combinatorial distributions, and quantum-enhanced sampling. Important limitations are mode collapse, difficult gradient estimation, sampling overhead, and uncertainty about whether the generated distribution offers value beyond classical generative models. 7. Quantum optimization for AIMany AI tasks involve optimization: feature selection, scheduling, portfolio construction, graph partitioning, and hyperparameter selection. A binary optimization problem can be expressed as a quadratic unconstrained binary optimization (QUBO): min_{x ∈ {0,1}n} xᵀQx + cᵀx where x is a binary decision vector, Q is a coefficient matrix, and c is a linear coefficient vector. Constraints can often be incorporated using penalty terms. For example, a requirement h(x)=0 may be represented by adding λ h(x)2, where λ must be large enough to discourage violations without overwhelming the original objective. QUBOs can be transformed into Ising Hamiltonians using the substitution xi = (1−si)/2, with si ∈ {−1,+1}. Quantum annealers and gate-based algorithms such as the quantum approximate optimization algorithm (QAOA) use different hardware and algorithmic assumptions. QAOA alternates a problem unitary and a mixing unitary; its parameters are optimized classically. Neither approach automatically solves general AI optimization faster than classical heuristics. A professional evaluation reports solution quality, time to solution, energy use, preprocessing, embedding or compilation overhead, number of repetitions, and the performance of classical heuristics. Comparing only the final objective value while ignoring these costs is misleading. 8. Worked example: a small quantum-kernel classifierConsider four two-dimensional observations, scaled so that each feature is an angle in [−π, π]: | Observation | x₁ | x₂ | Class |
|---|
| A | 0.20 | 0.10 | 0 | | B | 0.25 | 0.15 | 0 | | C | 2.80 | 2.90 | 1 | | D | 2.70 | 2.85 | 1 |
An angle-encoded circuit applies Ry(x1) to qubit 1 and Ry(x2) to qubit 2, followed by an entangling gate. A kernel estimate compares pairs of encoded states. Suppose repeated measurements produce the following estimated kernel matrix: | A | B | C | D |
|---|
| A | 1.00 | 0.96 | 0.08 | 0.10 | | B | 0.96 | 1.00 | 0.12 | 0.09 | | C | 0.08 | 0.12 | 1.00 | 0.95 | | D | 0.10 | 0.09 | 0.95 | 1.00 |
The matrix suggests high within-class similarity and low between-class similarity. A kernel classifier would train using this matrix, withholding at least one observation for testing or using cross-validation. The conclusion should be limited: this small example shows separability for the selected feature map and data, not a quantum advantage. A classical radial-basis-function kernel must be tested on the same splits, with preprocessing and hyperparameter tuning performed fairly. 9. Applied case: illustrative predictive maintenance studyBackground. A manufacturer records vibration, temperature, and electrical-current measurements from industrial motors. Unexpected failure is costly, but failures are rare and the sensor variables are correlated. Problem. The analytics team wants to determine whether a quantum kernel can improve early failure detection using a limited labelled data set. Analysis. The team first removes leakage, imputes missing values using training data only, standardizes features, and defines a time-based train–validation–test split. Because the raw sensor stream contains hundreds of variables, it applies a domain-approved dimensionality reduction method before quantum encoding. It then compares logistic regression, a classical support-vector machine with radial-basis kernel, gradient boosting, a quantum-kernel SVM, and a VQC. Approach. The quantum feature map uses six qubits and two repeated encoding layers. Kernel entries are estimated with a fixed shot budget on a simulator and on hardware. The study reports area under the precision–recall curve, recall at a fixed false-alarm rate, calibration, circuit executions, latency, and total preprocessing time. Confidence intervals are obtained through repeated time-respecting evaluation where feasible. Outcome. In this illustrative case, the quantum-kernel model matches but does not clearly exceed the classical SVM. Hardware noise reduces the separation of kernel values, while the cost of constructing the kernel matrix is substantial. The result is still useful: the team identifies which data reductions and circuit depths are feasible and avoids deploying an unsupported advantage claim. Learning points. Quantum models should be selected for a specific data geometry, not because they are quantum. Rare-event metrics must reflect operational decisions. Data preparation, circuit execution, and monitoring costs belong in the comparison. A non-advantage result is scientifically informative when the experiment is controlled and reproducible. 10. Assessing practical advantageA claim of quantum advantage requires more than higher test accuracy on a small data set. At minimum, the study should specify: - the problem definition and input-access assumptions;
- the classical baseline, including tuned modern methods;
- data splits, leakage controls, and random seeds;
- circuit depth, qubit count, shots, noise model, and hardware;
- preprocessing, state-preparation, compilation, and post-processing costs;
- statistical uncertainty and repeated trials;
- the resource being improved: accuracy, wall-clock time, energy, memory, sample complexity, or solution quality.
Useful distinctions are computational advantage, where asymptotic or measured resource use improves; practical advantage, where a complete workflow is better for a real user; and quantum utility, where a quantum component produces valuable results even without a proven asymptotic speedup. These terms should not be treated as interchangeable. 11. Explainability, governance, and responsible useQuantum models can be opaque because a prediction depends on a high-dimensional state and measurement process. Explainability techniques may include permutation tests, counterfactual analysis, sensitivity to encoded features, circuit ablation, local surrogate models, and comparison with interpretable classical models. Explanations should be validated for faithfulness rather than treated as automatically correct. Sensitive applications require attention to fairness, privacy, security, and accountability. Quantum processing does not remove obligations under data-protection, medical, financial, or safety regulation. Training data must have lawful provenance, and generated synthetic data must be checked for memorization and disclosure risk. In high-impact decisions, a human review pathway, audit logs, model versioning, and documented uncertainty are essential. 12. Best practices and contemporary directionGood QML practice includes starting with a precise business or scientific objective, using small reproducible experiments, normalizing and reducing data before encoding, selecting shallow problem-informed circuits, monitoring gradient and kernel statistics, and reporting complete resource costs. Noise-aware validation should distinguish simulator results from hardware results. Classical baselines should be strong, tuned, and evaluated on identical data splits. Current development trends include error mitigation, improved compilation, quantum neural tangent-kernel analysis, application-specific ansätze, quantum generative sampling, and combinations of classical representation learning with small quantum circuits. These directions are promising but remain active research areas. Evidence should be judged by reproducibility, scale, realistic input loading, and end-to-end comparisons rather than by theoretical circuit demonstrations alone. Chapter SummaryQuantum machine learning uses quantum states, circuits, and measurements within statistical-learning workflows. Feature maps encode classical data; quantum kernels compare encoded states; variational classifiers learn circuit parameters through hybrid optimization; clustering can use quantum similarities; generative circuits model probability distributions; and QUBO or QAOA formulations address selected optimization problems. The principal practical constraints are data loading, circuit depth, noise, shot cost, trainability, and interpretability. A meaningful advantage claim requires strong classical baselines, fair data splits, complete resource accounting, uncertainty analysis, and realistic hardware assumptions. At diploma level, the most valuable professional skill is not simply constructing a quantum model, but judging when it is justified and how its evidence should be communicated. Key TermsQuantum machine learning: Application of quantum computing concepts to learning, inference, or data analysis. Quantum feature map: A data-dependent quantum circuit that creates a representation of classical inputs. Data encoding: The process of converting classical information into a quantum state. Angle encoding: Encoding features as rotation angles in quantum gates. Amplitude encoding: Representing normalized data values as amplitudes of basis states. Quantum kernel: A similarity function estimated from overlaps between quantum feature states. Kernel matrix: A matrix whose entries are pairwise kernel similarities. Variational quantum classifier: A trainable parameterized quantum circuit used for classification. Ansatz: The chosen parameterized circuit structure. Observable: A quantum measurement operator whose expectation value is estimated. Shot: One execution and measurement of a quantum circuit. Barren plateau: A region where gradients become extremely small and training is difficult. Quantum generative model: A quantum model that learns or samples a probability distribution. QUBO: Quadratic unconstrained binary optimization formulation. QAOA: Quantum approximate optimization algorithm for combinatorial optimization. Quantum advantage: Demonstrated improvement over relevant classical methods under stated conditions. Trainability: The practical ability to optimize a model’s parameters. Data leakage: Use of information during training that would not be available at deployment. Explainability: The degree to which model behaviour can be understood and justified. Hybrid quantum–classical algorithm: An algorithm dividing computation between quantum and classical resources. Review Questions5 Short Answer Questions- What is the purpose of a quantum feature map?
- Why can amplitude encoding fail to provide a practical speedup despite using relatively few qubits?
- What does a quantum kernel measure?
- Define a barren plateau.
- Why must classical baselines be included in QML experiments?
5 Long Answer Questions- Explain the architecture and training cycle of a variational quantum classifier.
- Compare angle, basis, and amplitude encoding, including their practical trade-offs.
- Describe how a quantum kernel can be incorporated into a support-vector machine.
- Explain two quantum approaches to generative modelling and identify their evaluation challenges.
- Discuss the main sources of noise and computational cost in a near-term QML workflow.
3 Analytical / Application Questions- Design an evaluation plan for a quantum-kernel model for medical diagnosis. Specify data splitting, baselines, metrics, resource measurements, and governance controls.
- A VQC has high training accuracy but unstable validation accuracy and nearly zero gradients. Diagnose possible causes and propose a sequence of interventions.
- A company claims quantum advantage because its model achieves 2% higher accuracy than a classical model on 40 test cases. Critically assess the claim and list the evidence required before deployment.
Multiple Choice Questions with AnswersQuestion 1What is the main purpose of a quantum feature map? A. To convert classical data into a data-dependent quantum state B. To remove all measurement noise C. To replace the classical optimizer D. To guarantee quantum advantage Correct Answer: A. To convert classical data into a data-dependent quantum state Question 2For normalized quantum states, the squared-overlap kernel K(x,z) is generally in which interval? A. [−∞,∞] B. [0,1] C. [1,∞] D. [−1,1] Correct Answer: B. [0,1] Question 3Which component usually updates the parameters of a variational quantum classifier? A. A classical optimizer B. A measurement basis alone C. A file-compression algorithm D. A random label generator Correct Answer: A. A classical optimizer Question 4What is a common symptom of a barren plateau? A. Rapidly increasing gradient variance B. Gradients that become too small to guide training C. Perfect generalization on unseen data D. Elimination of shot noise Correct Answer: B. Gradients that become too small to guide training Question 5Which expression represents a QUBO objective? A. xᵀQx + cᵀx for binary x B. ∫x dx for continuous x only C. ∑ y_i log y_i without decisions D. A confusion matrix alone Correct Answer: A. xᵀQx + cᵀx for binary x Question 6Why is state-preparation cost important in evaluating quantum machine-learning advantage? A. It may dominate the total workflow cost B. It determines the labels automatically C. It makes all kernels positive definite D. It removes the need for validation Correct Answer: A. It may dominate the total workflow cost Question 7Which metric is often especially informative for rare-event detection? A. Area under the precision–recall curve B. Number of qubits alone C. Circuit depth without performance data D. Training-set size alone Correct Answer: A. Area under the precision–recall curve Question 8In a quantum generative model, measurement outcomes are used to estimate what? A. A probability distribution over outcomes B. The exact classical source code C. A guaranteed optimal classifier D. The number of training labels Correct Answer: A. A probability distribution over outcomes Question 9What is the most defensible interpretation when a quantum model matches a strong classical baseline but uses more resources? A. Quantum advantage has been proven B. The quantum model may be useful, but advantage has not been demonstrated C. The classical baseline is invalid automatically D. Hardware noise improves the evidence Correct Answer: B. The quantum model may be useful, but advantage has not been demonstrated Question 10Which practice best supports a credible QML comparison? A. Compare only against an untuned classical model B. Ignore preprocessing and compilation costs C. Use identical data splits and report complete resource costs D. Report training accuracy only Correct Answer: C. Use identical data splits and report complete resource costs
|