Scikit-learn compatible quantum machine learning library powered by PennyLane
Project description
psipose
Scikit-learn compatible quantum machine learning library powered by PennyLane.
Note: This project is in early development (v0.1 alpha). API may change.
Quick Start
Installation
# Clone and enter the directory
git clone https://github.com/dduyanhhoang/psipose.git
cd psipose
# Install dependencies with uv
uv sync --dev
# Or with pip
pip install -e ".[dev]"
Classification with VQCClassifier
from psipose import VQCClassifier
from sklearn.datasets import make_moons
from sklearn.model_selection import train_test_split
X, y = make_moons(n_samples=100, noise=0.1)
X_train, X_test, y_train, y_test = train_test_split(X, y)
clf = VQCClassifier(n_qubits=2, n_iter=100, random_state=42)
clf.fit(X_train, y_train)
accuracy = clf.score(X_test, y_test)
print(f"Accuracy: {accuracy:.2%}")
Quantum Kernel SVM (QSVC)
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)
accuracy = svc.score(X_test, y_test)
print(f"QSVC Accuracy: {accuracy:.2%}")
Regression with VQCRegressor
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)
score = reg.score(X_test, y_test)
print(f"R^2 score: {score:.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 |
Encoders & Ansatze
Encoders map classical data to quantum states:
AngleEncoder(rotation="Y")— one feature per qubit as a rotation angleAmplitudeEncoder()— encodes a2**n_qubits-dim vector as a quantum state
Ansatze provide parameterized quantum circuits:
HardwareEfficientAnsatz(n_qubits, layers)— alternating rotation + entanglement layersStronglyEntanglingAnsatz(n_qubits, layers)— PennyLane'sStronglyEntanglingLayers
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 dependencies (including dev)
uv sync --dev
# Install pre-commit hooks
pre-commit install
Running Tests
# Run all tests (handles ROS plugin conflicts)
./scripts/test.sh
# Run fast tests only (skip slow)
pytest tests/ -k "not slow"
# Run a single test file
pytest tests/test_vqc_regressor.py
Linting and Formatting
# Check linting
uv run ruff check psipose tests
# Format code
uv run ruff format psipose tests
# Or use the scripts
./scripts/lint.sh
./scripts/format.sh
Project Structure
psipose/
├── psipose/ # Main package
│ ├── __init__.py # Public API exports
│ ├── base.py # QuantumEstimator base class (sklearn BaseEstimator)
│ ├── encoders/ # Data encoding circuits
│ │ ├── _base.py # BaseEncoder abstract class
│ │ ├── angle.py # AngleEncoder (RY/RX/RZ rotations)
│ │ └── amplitude.py # AmplitudeEncoder (state amplitude encoding)
│ ├── ansatze/ # Parameterized quantum circuits
│ │ ├── _base.py # BaseAnsatz abstract class
│ │ ├── hardware_efficient.py # HardwareEfficientAnsatz
│ │ └── strongly_entangling.py # StronglyEntanglingAnsatz
│ ├── estimators/ # sklearn-compatible estimators
│ │ ├── vqc.py # VQCClassifier (binary & multi-class)
│ │ ├── qsvc.py # QSVC (quantum kernel SVM)
│ │ └── vqc_regressor.py # VQCRegressor (quantum regression)
│ ├── kernels/ # Quantum kernels
│ │ └── fidelity.py # FidelityQuantumKernel (kernel matrix via fidelity)
│ └── utils/ # Utility helpers
├── tests/ # Test suite organized by module
├── scripts/ # Development shell scripts
│ ├── clean_commit.sh # Automated conventional commit script
│ ├── format.sh # Format code with ruff
│ ├── lint.sh # Lint check with ruff
│ ├── setup-hooks.sh # Install git hooks
│ └── test.sh # Run tests (handles ROS conflicts)
├── .github/workflows/ # CI configuration
└── pyproject.toml # Project metadata, dependencies, tool configs
Dependencies
- Required:
pennylane,numpy,scikit-learn - Dev:
pytest,pytest-cov,ruff,pre-commit,mypy
Roadmap
- Phase 0: Project setup
- Phase 1: Minimal VQCClassifier (AngleEncoder + HardwareEfficientAnsatz)
- Phase 2: Full VQCClassifier (multi-class, predict_proba)
- Phase 3: Quantum kernels (FidelityQuantumKernel, QSVC)
- Phase 4: Regression (VQCRegressor)
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
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 psipose-0.1.2.tar.gz.
File metadata
- Download URL: psipose-0.1.2.tar.gz
- Upload date:
- Size: 28.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5ef2fa6e065817af935316cabbf5ba8fd1c458cee284f69636c260d7b8ca7f2f
|
|
| MD5 |
5d4f3a47f59cf384471db939a20cb145
|
|
| BLAKE2b-256 |
d1729c697c57f9639abf4f5b577678e00ad8cb95938cc7ffa7d4874d73f02638
|
Provenance
The following attestation bundles were made for psipose-0.1.2.tar.gz:
Publisher:
release.yml on dduyanhhoang/psipose
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
psipose-0.1.2.tar.gz -
Subject digest:
5ef2fa6e065817af935316cabbf5ba8fd1c458cee284f69636c260d7b8ca7f2f - Sigstore transparency entry: 1428106636
- Sigstore integration time:
-
Permalink:
dduyanhhoang/psipose@f35149daf29cbfeb4802367074ee2f44eb83771c -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/dduyanhhoang
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f35149daf29cbfeb4802367074ee2f44eb83771c -
Trigger Event:
push
-
Statement type:
File details
Details for the file psipose-0.1.2-py3-none-any.whl.
File metadata
- Download URL: psipose-0.1.2-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a9a929a27e3ac09fed7c7b12901bb846e205b9f819a7fec3e57080c97f8363c6
|
|
| MD5 |
2027ab54ed5bb838b1ad0b3c2e703e2f
|
|
| BLAKE2b-256 |
ed23810d3fe0bc086fc77e8bd28c61e09a9f685f1d59f3209a3e79c7f93dd6c0
|
Provenance
The following attestation bundles were made for psipose-0.1.2-py3-none-any.whl:
Publisher:
release.yml on dduyanhhoang/psipose
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
psipose-0.1.2-py3-none-any.whl -
Subject digest:
a9a929a27e3ac09fed7c7b12901bb846e205b9f819a7fec3e57080c97f8363c6 - Sigstore transparency entry: 1428106763
- Sigstore integration time:
-
Permalink:
dduyanhhoang/psipose@f35149daf29cbfeb4802367074ee2f44eb83771c -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/dduyanhhoang
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f35149daf29cbfeb4802367074ee2f44eb83771c -
Trigger Event:
push
-
Statement type: