A diagnostic suite for Quantum Machine Learning encodings.
Project description
HilbertLens 🔬
HilbertLens is a diagnostic tool for Quantum Machine Learning (QML). It visualizes the hidden geometry of your quantum encodings and "diagnoses" their capacity to learn complex data.
Instead of blindly training Variational Quantum Circuits (VQC) and guessing why they fail, HilbertLens tells you:
- Spectrum Analysis: Does the circuit have enough bandwidth (expressibility) for the data?
- Geometry Analysis: Does the encoding preserve the topological structure of the data?
📦 Installation
pip install .
For development (so edits are reflected immediately):
pip install -e .
🚀 Quick Start
1. The "Doctor" Check
Pass your circuit to the QuantumLens and ask for a diagnosis.
import hilbertlens as hl
from qiskit.circuit import ParameterVector, QuantumCircuit
# Define your circuit
x = ParameterVector('x', 2)
qc = QuantumCircuit(2)
qc.h([0, 1])
qc.rz(x[0], 0)
qc.rz(x[1], 1)
qc.cx(0, 1) # Entanglement
# Initialize Lens
lens = hl.QuantumLens(qc, params=list(x), framework='qiskit')
# Run Diagnosis (Auto-runs Spectrum and Geometry checks)
lens.diagnose()
2. Manual Inspection
You can run individual checks and save the plots.
# Check Frequency Spectrum (Capacity)
lens.spectrum(mode='global', save_path="spectrum.png")
# Check Geometry Preservation (using synthetic Swiss Roll)
lens.geometry(save_path="geometry.png")
🏥 Understanding the Report
- [GOLD STANDARD]: Your circuit has a rich spectrum (multiple frequencies) AND preserves geometry. It is ready for research.
- [SAFE BUT SIMPLE]: Your circuit is linear (). It will work on simple data (Iris) but underfit complex data (Moons).
- [BROKEN GEOMETRY]: Your circuit destroys the data structure (e.g., score < 0.5). Check your data scaling!
🔧 Supported Frameworks
- Qiskit (Native support)
- PennyLane (Auto-detected if installed)
Sample Output
Testing with Real Data: Two Moons
Data Shape: (200, 2)
Features: 2
i. Quantum Circuit
Circuit Created: 2-Qubit Entangled Network
[HilbertLens] Initialized for framework: qiskit
ii. Geometry Check (Two Moons)
Status: Analyzing Geometry
- Geometry Score (Spearman Correlation):
0.9182 - Output:
moons_geometry.png
iii. Spectrum Check
Status: Computing Spectrum
Mode: Global
Dominant Frequencies — Global Sweep
- k = 1.0 | Power:
0.446 - k = 3.0 | Power:
0.442 - k = 2.0 | Power:
0.112
Output: moons_spectrum.png
HILBERTLENS DIAGNOSIS REPORT
[1] Spectrum Analysis — Capacity & Expressibility
- Active Frequencies: 3 (Richness)
- Max Frequency:
k = 3.0(Bandwidth) - Category: High Capacity (Rich Expressibility)
- Assessment: Complex spectrum with three active frequencies; capable of deep nuance.
- Advice: Gold standard. Capable of universal classification.
[2] Geometry Analysis — Inductive Bias
- Preservation Score:
0.9182(Spearman ρ) - Category: Excellent Preservation
- Assessment: The quantum kernel faithfully preserves the topological structure of the input data.
[3] Final Verdict
[GOLD STANDARD] READY FOR RESEARCH
Your circuit exhibits High Capacity (Rich Spectrum) and Stable Geometry.
It can learn complex decision boundaries without breaking data topology.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hilbertlens-0.1.2.tar.gz.
File metadata
- Download URL: hilbertlens-0.1.2.tar.gz
- Upload date:
- Size: 19.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
611c17a78be60669dde8152f2a0b920439246590ea4ee0918d7b41a5e9554b47
|
|
| MD5 |
6d9930c60707a800d37bd77a9bfc9831
|
|
| BLAKE2b-256 |
06318f32486ded2f7101db886ed63e427395ff93e996a1fd603c787935eaf5fe
|
File details
Details for the file hilbertlens-0.1.2-py3-none-any.whl.
File metadata
- Download URL: hilbertlens-0.1.2-py3-none-any.whl
- Upload date:
- Size: 16.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7995010ae80aab386caf11f5e0b2617dfad6246546da3b0f1e5d9c52b88adf59
|
|
| MD5 |
d4f32631cf2637cfae8d2c474751c442
|
|
| BLAKE2b-256 |
b38c74549bdb82bf5ec68312ee8d0c50cff560027727ec60ca9f0472f9cb1303
|