qek.kernel
source package qek.kernel
The Quantum Evolution Kernel itself, for use in a machine-learning pipeline.
Classes
-
FastQEK — FastQEK class.
-
IntegratedQEK — A variant of the Quantum Evolution Kernel that supports fit/transform/fit_transform from raw data (graphs).
source class FastQEK(mu: float, size_max: int | None = None, similarity: Callable[[NDArray[np.floating], NDArray[np.floating]], np.floating] | None = None)
Bases : BaseKernel[ProcessedData]
FastQEK class.
Initialize the kernel.
Attributes
-
- X (Sequence[ProcessedData]) — Training data used for fitting the kernel.
-
- kernel_matrix (np.ndarray) — Kernel matrix. This is assigned in the
fit()
method
Training parameters
mu (float): Scaling factor for the Jensen-Shannon divergence
size_max (int, optional): If specified, only consider the first size_max
qubits of bitstrings. Otherwise, consider all qubits. You may use this
to trade precision in favor of speed.
Parameters
-
mu : float — Scaling factor for the Jensen-Shannon divergence
-
size_max : int, optional — If specified, only consider the first
size_max
qubits of bitstrings. Otherwise, consider all qubits. You may use this to trade precision in favor of speed. -
similarity : optional — If specified, a custom similarity metric to use. Otherwise, use the Jensen-Shannon divergence.
Note: This class does not accept raw data, but rather ProcessedData
. See
class IntegratedQEK for a subclass that provides a more powerful API,
at the expense of performance.
Methods
-
to_processed_data — Convert the raw data into features.
source method FastQEK.to_processed_data(X: Sequence[ProcessedData]) → Sequence[ProcessedData]
Convert the raw data into features.
source class IntegratedQEK(mu: float, extractor: BaseExtractor[GraphType], size_max: int | None = None, similarity: Callable[[NDArray[np.floating], NDArray[np.floating]], np.floating] | None = None)
Bases : BaseKernel[GraphType]
A variant of the Quantum Evolution Kernel that supports fit/transform/fit_transform from raw data (graphs).
Initialize an IntegratedQEK
Performance note
This class uses an extractor to convert the raw data into features. This can be very slow if you use, for instance, a remote QPU, as the waitlines to access a QPU can be very long. If you are using this in an interactive application or a server, this will block the entire thread during the wait.
We recommend using this class only with local emulators.
Training parameters
mu (float): Scaling factor for the Jensen-Shannon divergence
extractor: An extractor (e.g. a QPU or a Quantum emulator) used to conver the raw data (graphs) into features.
size_max (int, optional): If specified, only consider the first size_max
qubits of bitstrings. Otherwise, consider all qubits. You may use this
to trade precision in favor of speed.
similarity (optional): If specified, a custom similarity metric to use. Otherwise,
use the Jensen-Shannon divergence.
Parameters
-
mu : float — Scaling factor for the Jensen-Shannon divergence
-
extractor : BaseExtractor[GraphType] — An extractor (e.g. a QPU or a Quantum emulator) used to conver the raw data (graphs) into features.
-
size_max : int, optional — If specified, only consider the first
size_max
qubits of bitstrings. Otherwise, consider all qubits. You may use this to trade precision in favor of speed. -
similarity : optional — If specified, a custom similarity metric to use. Otherwise, use the Jensen-Shannon divergence.
Methods
-
to_processed_data — Convert the raw data into features.
source method IntegratedQEK.to_processed_data(X: Sequence[GraphType]) → Sequence[ProcessedData]
Convert the raw data into features.
Performance note
This method can can be very slow if you use, for instance, a remote QPU, as the waitlines to access a QPU can be very long. If you are using this in an interactive application or a server, this will block the entire thread during the wait.