This quantum kernel approach was introduced in the landmark paper:
Havlíček et al. (2019), “Supervised learning with quantum-inspired
kernel” (arXiv:1904.01567). The paper demonstrates how quantum circuits
can implicitly define kernel functions that may provide quantum advantage
for classification tasks.
The kernel computation uses the overlap circuit method: by applying the
adjoint of the encoding circuit for x_j after the encoding for x_i,
the probability of measuring the all-zeros state equals the squared
fidelity between the two encoded quantum states.
Parameters:
feature_map (FeatureMap, optional) – The quantum feature map. If None, uses AngleFeatureMap() with n_qubits.
n_qubits (int, default=4) – Number of qubits. Only used if feature_map is None.
A support vector machine that uses a quantum kernel to implicitly
map data into a high-dimensional quantum feature space. The kernel
is computed as the fidelity (squared inner product) between quantum-
encoded states, following the quantum kernel method of Havlíček et al.
(2019, arXiv:1904.01567).
The implementation:
1. Encodes data using a quantum feature map
2. Computes the quantum kernel matrix (Gram matrix)
3. Trains a classical SVM with precomputed kernel
This hybrid approach leverages quantum computers to generate kernel
matrices that may be classically intractable to compute, while using
well-established classical SVM training.
Parameters:
n_qubits (int, default=4) – Number of qubits for the quantum circuit.
feature_map (FeatureMap, optional) – Quantum feature map for data encoding. Default: AngleFeatureMap()
device (str, default="default.qubit") – PennyLane device for simulation.
C (float, default=1.0) – Regularization parameter. The strength of regularization is
inversely proportional to C.
shrinking (bool, default=True) – Whether to use the shrinking heuristic.
probability (bool, default=False) – Whether to enable probability estimates.
tol (float, default=1e-3) – Tolerance for stopping criterion.
cache_size (float, default=200) – Kernel cache size in MB.
class_weight (dict or "balanced", optional) – Class weights for imbalanced datasets.
Configure whether metadata should be requested to be passed to the fit method.
Note that this method is only relevant when this estimator is used as a
sub-estimator within a meta-estimator and metadata routing is enabled
with enable_metadata_routing=True (see sklearn.set_config()).
Please check the User Guide on how the routing
mechanism works.
The options for each parameter are:
True: metadata is requested, and passed to fit if provided. The request is ignored if metadata is not provided.
False: metadata is not requested and the meta-estimator will not pass it to fit.
None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.
str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (sklearn.utils.metadata_routing.UNCHANGED) retains the
existing request. This allows you to change the request for some
parameters and not others.
Added in version 1.3.
Parameters:
sample_weight (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for sample_weight parameter in fit.
Returns:
self – The updated object.
Return type:
object
The QSVC uses a quantum kernel matrix computed via fidelity
between encoded quantum states, then delegates to sklearn.svm.SVC.