Utilities API
This page documents utility functions and helper classes used throughout the quantum data embedding suite.
Data Validation and Preprocessing
validate_data
validate_data(X, n_qubits)
Validate and preprocess data for quantum embedding.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X
|
array - like
|
Input data |
required |
n_qubits
|
int
|
Number of qubits available |
required |
Returns:
Name | Type | Description |
---|---|---|
X |
ndarray
|
Validated and potentially reshaped data |
Source code in quantum_data_embedding_suite\utils.py
normalize_data
normalize_data(X, method='minmax', feature_range=(0, 2 * np.pi))
Normalize data for quantum embedding.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X
|
array - like
|
Input data |
required |
method
|
str
|
Normalization method ('minmax', 'standard', 'unit') |
'minmax'
|
feature_range
|
tuple
|
Target range for minmax scaling |
(0, 2*pi)
|
Returns:
Name | Type | Description |
---|---|---|
X_normalized |
ndarray
|
Normalized data |
Source code in quantum_data_embedding_suite\utils.py
pad_features
pad_features(X, target_features)
Pad features to match target dimension.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X
|
array - like
|
Input data |
required |
target_features
|
int
|
Target number of features |
required |
Returns:
Name | Type | Description |
---|---|---|
X_padded |
ndarray
|
Data padded to target dimension |
Source code in quantum_data_embedding_suite\utils.py
reduce_features
reduce_features(X, target_features, method='pca')
Reduce feature dimension using classical methods.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X
|
array - like
|
Input data |
required |
target_features
|
int
|
Target number of features |
required |
method
|
str
|
Reduction method ('pca', 'truncate', 'average') |
'pca'
|
Returns:
Name | Type | Description |
---|---|---|
X_reduced |
ndarray
|
Data with reduced features |
Source code in quantum_data_embedding_suite\utils.py
Data Generation and Analysis
generate_random_data
generate_random_data(n_samples, n_features, data_type='gaussian', seed=None)
Generate random data for testing.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n_samples
|
int
|
Number of samples |
required |
n_features
|
int
|
Number of features |
required |
data_type
|
str
|
Type of random data ('gaussian', 'uniform', 'sphere') |
'gaussian'
|
seed
|
int
|
Random seed for reproducibility |
None
|
Returns:
Name | Type | Description |
---|---|---|
X |
ndarray
|
Random data |
Source code in quantum_data_embedding_suite\utils.py
compute_pairwise_distances
compute_pairwise_distances(X)
Compute pairwise Euclidean distances.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X
|
array - like
|
Input data |
required |
Returns:
Name | Type | Description |
---|---|---|
distances |
ndarray
|
Pairwise distance matrix |
Source code in quantum_data_embedding_suite\utils.py
compute_data_statistics
compute_data_statistics(X)
Compute basic statistics of the data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X
|
array - like
|
Input data |
required |
Returns:
Name | Type | Description |
---|---|---|
stats |
dict
|
Dictionary containing data statistics |
Source code in quantum_data_embedding_suite\utils.py
estimate_optimal_qubits
estimate_optimal_qubits(X, embedding_type='angle')
Estimate optimal number of qubits for data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X
|
array - like
|
Input data |
required |
embedding_type
|
str
|
Type of embedding |
'angle'
|
Returns:
Name | Type | Description |
---|---|---|
n_qubits |
int
|
Recommended number of qubits |
Source code in quantum_data_embedding_suite\utils.py
check_quantum_advantage_potential
check_quantum_advantage_potential(X, y=None)
Assess potential for quantum advantage on given data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X
|
array - like
|
Input features |
required |
y
|
array - like
|
Target labels |
None
|
Returns:
Name | Type | Description |
---|---|---|
assessment |
dict
|
Dictionary containing quantum advantage potential assessment |
Source code in quantum_data_embedding_suite\utils.py
Visualization Functions
These visualization functions are available in the visualization
module:
plot_kernel_comparison
plot_kernel_comparison(K_quantum, K_classical, output_file=None, figsize=(12, 5))
Plot comparison between quantum and classical kernel matrices.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
K_quantum
|
array - like
|
Quantum kernel matrix |
required |
K_classical
|
array - like
|
Classical kernel matrix |
required |
output_file
|
str
|
Path to save the plot |
None
|
figsize
|
tuple
|
Figure size (width, height) |
(12, 5)
|
Source code in quantum_data_embedding_suite\visualization.py
plot_expressibility_analysis
plot_expressibility_analysis(embeddings, expressibility_scores, output_file=None, figsize=(10, 6))
Plot expressibility analysis across different embeddings.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
embeddings
|
list of str
|
Embedding names |
required |
expressibility_scores
|
list of float
|
Expressibility scores for each embedding |
required |
output_file
|
str
|
Path to save the plot |
None
|
figsize
|
tuple
|
Figure size (width, height) |
(10, 6)
|
Source code in quantum_data_embedding_suite\visualization.py
plot_kernel_eigenspectrum
plot_kernel_eigenspectrum(K, title='Kernel Eigenspectrum', output_file=None, figsize=(8, 6))
Plot eigenspectrum of a kernel matrix.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
K
|
array - like
|
Kernel matrix |
required |
title
|
str
|
Plot title |
"Kernel Eigenspectrum"
|
output_file
|
str
|
Path to save the plot |
None
|
figsize
|
tuple
|
Figure size (width, height) |
(8, 6)
|
Source code in quantum_data_embedding_suite\visualization.py
plot_embedding_landscape
plot_embedding_landscape(X, y=None, embedding_type='Unknown', output_file=None, figsize=(10, 8))
Plot 2D visualization of the embedding landscape.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X
|
array - like
|
Data points (will be reduced to 2D if necessary) |
required |
y
|
array - like
|
Labels for coloring |
None
|
embedding_type
|
str
|
Type of embedding for plot title |
"Unknown"
|
output_file
|
str
|
Path to save the plot |
None
|
figsize
|
tuple
|
Figure size (width, height) |
(10, 8)
|
Source code in quantum_data_embedding_suite\visualization.py
plot_gradient_analysis
plot_gradient_analysis(gradients, parameter_names=None, output_file=None, figsize=(12, 5))
Plot gradient analysis for trainability assessment.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
gradients
|
array - like
|
Gradient values (can be 1D or 2D) |
required |
parameter_names
|
list of str
|
Names of parameters |
None
|
output_file
|
str
|
Path to save the plot |
None
|
figsize
|
tuple
|
Figure size (width, height) |
(12, 5)
|
Source code in quantum_data_embedding_suite\visualization.py
plot_kernel_alignment_heatmap
plot_kernel_alignment_heatmap(alignments, embedding_names, output_file=None, figsize=(8, 6))
Plot kernel alignment heatmap between different embeddings.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
alignments
|
array - like
|
Kernel alignment matrix |
required |
embedding_names
|
list of str
|
Names of embeddings |
required |
output_file
|
str
|
Path to save the plot |
None
|
figsize
|
tuple
|
Figure size (width, height) |
(8, 6)
|
Source code in quantum_data_embedding_suite\visualization.py
create_embedding_dashboard
create_embedding_dashboard(results, output_file=None, figsize=(16, 12))
Create a comprehensive dashboard for embedding analysis.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
results
|
dict
|
Dictionary containing analysis results |
required |
output_file
|
str
|
Path to save the plot |
None
|
figsize
|
tuple
|
Figure size (width, height) |
(16, 12)
|
Source code in quantum_data_embedding_suite\visualization.py
create_interactive_kernel_plot
create_interactive_kernel_plot(K, labels=None)
Create interactive kernel matrix plot using Plotly.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
K
|
array - like
|
Kernel matrix |
required |
labels
|
array - like
|
Sample labels |
None
|
Returns:
Name | Type | Description |
---|---|---|
fig |
plotly figure
|
Interactive plot figure |