qbiocode.embeddings.embed module#
Summary#
Functions:
This function applies the specified embedding technique to the training and test datasets. |
|
This function generates quantum circuits, computes projections of the data onto these circuits. |
Reference#
- pqk(X_train, X_test, args, store=False, data_key='', encoding='Z', data_map=True, primitive='estimator', entanglement='linear', reps=2)[source]#
This function generates quantum circuits, computes projections of the data onto these circuits. It uses a feature map to encode the data into quantum states and then measures the expectation values of Pauli operators to obtain the features. This function requires a quantum backend (simulator or real quantum hardware) for execution. It supports various configurations such as encoding methods, entanglement strategies, and repetitions of the feature map. Optionally the results are saved to files for training and test projections.
- Parameters:
X_train (np.ndarray) – Training data features.
X_test (np.ndarray) – Test data features.
args (dict) – Arguments containing backend and other configurations.
store (bool) – If true projections are stored, using data_key as indefitier
data_key (str) – Key for the dataset, default is ‘’.
encoding (str) – Encoding method for the quantum circuit, default is ‘Z’.
data_map (bool) – If true ensures that all multiplicative factors of data features inside single qubit gates are 1.0. Not applicable for Hejsemberg feature maps
primitive (str) – Primitive type to use, default is ‘estimator’.
entanglement (str) – Entanglement strategy, default is ‘linear’.
reps (int) – Number of repetitions for the feature map, default is 2.
- Returns:
A dictionary containing evaluation metrics and model parameters.
- Return type:
modeleval (dict)
- get_embeddings(embedding, X_train, X_test, n_neighbors=30, n_components=None, method=None)[source]#
This function applies the specified embedding technique to the training and test datasets.
- Parameters:
embedding (str) – The embedding technique to use. Options are ‘none’, ‘pca’, ‘nmf’, ‘lle’, ‘isomap’, ‘spectral’, or ‘umap’.
X_train (array-like) – The training dataset.
X_test (array-like) – The test dataset.
n_neighbors (int, optional) – Number of neighbors for certain embeddings. Defaults to 30.
n_components (int, optional) – Number of components for the embedding. If None, it defaults to the number of features in X_train.
method (str, optional) – Method for Locally Linear Embedding. Defaults to None.
- Returns:
Transformed training and test datasets.
- Return type:
tuple