Skip to main content

Scikit-learn compatible quantum machine learning library powered by PennyLane

Project description

psipose

Documentation GitHub PyPI

A scikit-learn-compatible quantum machine learning library powered by PennyLane.

Drop in quantum estimators — classifiers, regressors, and kernels — that follow scikit-learn's API conventions. Use them seamlessly in existing sklearn workflows like Pipeline, GridSearchCV, and cross_val_score.

Note: This project is in early development (v0.1.x alpha). API may change.

Quick Start

Installation

# With uv (recommended)
uv pip install psipose

# With pip
pip install psipose

Your First Quantum Classifier

from psipose import VQCClassifier
from sklearn.datasets import make_moons
from sklearn.model_selection import train_test_split

# Generate data
X, y = make_moons(n_samples=100, noise=0.1)
X_train, X_test, y_train, y_test = train_test_split(X, y)

# Train quantum classifier
clf = VQCClassifier(n_qubits=2, n_iter=100, random_state=42)
clf.fit(X_train, y_train)

# Evaluate
print(f"Accuracy: {clf.score(X_test, y_test):.2%}")

Quantum Kernel SVM

from psipose import QSVC
from sklearn.datasets import make_circles

X, y = make_circles(n_samples=100, noise=0.1, factor=0.3)
X_train, X_test, y_train, y_test = train_test_split(X, y)

svc = QSVC(n_qubits=2, random_state=42)
svc.fit(X_train, y_train)

print(f"QSVC Accuracy: {svc.score(X_test, y_test):.2%}")

Quantum Regression

from psipose import VQCRegressor
from sklearn.datasets import make_regression

X, y = make_regression(n_samples=100, n_features=2, noise=0.1)
X_train, X_test, y_train, y_test = train_test_split(X, y)

reg = VQCRegressor(n_qubits=2, n_iter=100, random_state=42)
reg.fit(X_train, y_train)

print(f"R^2 score: {reg.score(X_test, y_test):.2%}")

Available Estimators

Estimator Type Description
VQCClassifier Classifier Variational Quantum Classifier with trainable ansatz
QSVC Classifier Quantum kernel SVM using fidelity-based kernels
VQCRegressor Regressor Variational Quantum Regressor for continuous outputs

Architecture

psipose uses composition over inheritance — estimators combine independent, swappable components:

Encoders map classical data to quantum states:

  • AngleEncoder(rotation="Y") — one feature per qubit as a rotation angle
  • AmplitudeEncoder() — encodes a 2**n_qubits-dim vector as a quantum state

Ansatze provide parameterized quantum circuits:

  • HardwareEfficientAnsatz(n_qubits, layers) — alternating rotation + entanglement layers
  • StronglyEntanglingAnsatz(n_qubits, layers) — PennyLane's StronglyEntanglingLayers

All components are composable — swap encoders and ansatze independently:

from psipose import VQCClassifier, AmplitudeEncoder, StronglyEntanglingAnsatz

clf = VQCClassifier(
    encoder=AmplitudeEncoder(),
    ansatz=StronglyEntanglingAnsatz(layers=3),
    n_qubits=2,
    n_iter=200,
)

Development

Setup

# Install with dev dependencies
uv sync --dev

# Install pre-commit hooks
pre-commit install

Testing & Linting

# Run tests (handles ROS plugin conflicts)
./scripts/test.sh

# Run fast tests only (skip slow)
pytest tests/ -k "not slow"

# Lint and format
uv run ruff check psipose tests
uv run ruff format psipose tests

Project Structure

psipose/
├── psipose/              # Main package
│   ├── __init__.py       # Public API exports
│   ├── base.py           # QuantumEstimator base class
│   ├── encoders/         # Data encoding circuits
│   ├── ansatze/          # Parameterized quantum circuits
│   ├── estimators/       # sklearn-compatible estimators
│   ├── kernels/          # Quantum kernels
│   └── utils/            # Utility helpers
├── tests/                # Test suite
├── docs/                 # Sphinx documentation
├── scripts/              # Development scripts
└── pyproject.toml        # Project configuration

Dependencies

  • Required: pennylane>=0.40.0, numpy>=1.21.0, scikit-learn>=1.2.0
  • Dev: pytest, ruff, pre-commit, mypy

Roadmap

  • Phase 0: Project setup
  • Phase 1: Minimal VQCClassifier
  • Phase 2: Full VQCClassifier (multi-class, predict_proba)
  • Phase 3: Quantum kernels (FidelityQuantumKernel, QSVC)
  • Phase 4: Regression (VQCRegressor)
  • Phase 5: Additional quantum kernels
  • Phase 6: Hardware backend support

License

MIT - see LICENSE for details.

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

psipose-0.1.3.tar.gz (27.9 kB view details)

Uploaded Source

Built Distribution

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

psipose-0.1.3-py3-none-any.whl (27.2 kB view details)

Uploaded Python 3

File details

Details for the file psipose-0.1.3.tar.gz.

File metadata

  • Download URL: psipose-0.1.3.tar.gz
  • Upload date:
  • Size: 27.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for psipose-0.1.3.tar.gz
Algorithm Hash digest
SHA256 7defaf08c290c7c5872979673c2139dc3fbef9ec0275a139268b1197a72bd1c4
MD5 88861dc0bc1b23acb446280226e5dea7
BLAKE2b-256 84040827ff522dc9e6fed153812a71289cfb43e33f85c5d997654fb44aa0c73b

See more details on using hashes here.

Provenance

The following attestation bundles were made for psipose-0.1.3.tar.gz:

Publisher: release.yml on dduyanhhoang/psipose

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file psipose-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: psipose-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 27.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for psipose-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 19cec8d7886a21398019ced709a85dd16d40de0c1ff8acdedd3e66823484979f
MD5 441b4822038be2642d17a6878dad538b
BLAKE2b-256 437e7ae55c41c487ce537e6b9b48fc53272847374012e83742edcbb91cc210fa

See more details on using hashes here.

Provenance

The following attestation bundles were made for psipose-0.1.3-py3-none-any.whl:

Publisher: release.yml on dduyanhhoang/psipose

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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