Skip to main content

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:

  1. Spectrum Analysis: Does the circuit have enough bandwidth (expressibility) for the data?
  2. 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

Test Script: Two Moons

Data Shape: (200, 2)
Features: 2

i. Quantum Circuit

Circuit Created: 2-Qubit Entangled Network

Two Moons Encoding Circuit

[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 Two Moons Spectrum

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

hilbertlens-0.1.0.tar.gz (18.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hilbertlens-0.1.0-py3-none-any.whl (15.4 kB view details)

Uploaded Python 3

File details

Details for the file hilbertlens-0.1.0.tar.gz.

File metadata

  • Download URL: hilbertlens-0.1.0.tar.gz
  • Upload date:
  • Size: 18.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.12

File hashes

Hashes for hilbertlens-0.1.0.tar.gz
Algorithm Hash digest
SHA256 be9e2a51089d54154ba192e5b6b8139be2769597d1774e3e2be4af2898559bb1
MD5 3eb0120abd175dbf9a6a7f6a6204bd47
BLAKE2b-256 12b31acb243bc9200c616dfdfbe08d522a388d8add79c023c221c71158a4d5c0

See more details on using hashes here.

File details

Details for the file hilbertlens-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: hilbertlens-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 15.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.12

File hashes

Hashes for hilbertlens-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 52b4d07380bac6c9b56f95ef9e8b3d459cfa7bb6c2fa7aee9f16af5fdacb4714
MD5 893363c15e1883d73347669c77af4b72
BLAKE2b-256 481b7f2df5cc9e9c68b4f6bbbfddc58bc26eec68b559ef2597b1343b5aa0afa5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page