Skip to main content

Compare quantum ML algorithms against classical ML — with automatic QML recommendations

Project description

quantum-ml-comparator

tests lint PyPI version Python versions License: MIT codecov DOI

Developed at Orbion GmbH.

Compare quantum machine learning algorithms against classical ML — with automatic QML recommendations.

A general-purpose, open-source framework to benchmark QML vs classical ML on your own datasets. Tell it what classical algorithm you're using, and it recommends which quantum algorithms to compare against, explains why, and runs the comparison for you.

Install

pip install -e .

For molecular VQE support:

pip install -e ".[molecules]"

Quickstart (3 lines)

from qmc import Benchmark

bench = Benchmark(dataset="iris", classical_methods=["MLP", "SVM", "RF"])
bench.run()
bench.report("results/")

Quantum methods are auto-recommended based on your classical methods.

The QML Recommender

Don't know which quantum algorithm to try? Ask:

from qmc import print_recommendations

print_recommendations("RandomForest")

Output:

[PRIMARY] Quantum Kernel Ensemble  (difficulty: medium)
  Ensemble of quantum-kernel SVMs on bootstrap samples, mimicking Random Forest's bagging.
  Rationale: Combining multiple quantum kernel models reduces variance, similar to how
             Random Forest aggregates decision trees.
  Circuit:   8 qubits, 4 layers

[SECONDARY] VQC  (difficulty: easy)
  Variational Quantum Classifier as a single strong learner replacing the tree ensemble.
  Rationale: A sufficiently expressive VQC can match an ensemble of weak learners.

Supported classical algorithms: SVM, MLP, Random Forest, Logistic Regression, k-NN, XGBoost, Naive Bayes, PCA (plus any algorithm falls back to general-purpose VQC/QuantumKernel).

What's Included

Classical models

MLP (PyTorch), SVM, Random Forest, Logistic Regression, k-NN, Gradient Boosting, Naive Bayes, Decision Tree.

Quantum circuits

  • VQC — Variational Quantum Classifier (binary + multiclass)
  • Quantum Kernel — IQP-style feature map + precomputed SVM
  • QNP ansatz — Particle-number-preserving gates (Anselmetti et al.)
  • HEA ansatz — StronglyEntanglingLayers (generic)
  • Plus circuit factory templates for custom designs

Molecular VQE

Run VQE on standard benchmark molecules (H2, HeH+, LiH, H2O) with QNP or HEA ansatze. Compare ansatz performance:

from qmc.molecules import VQERunner

runner = VQERunner(molecule="H2", ansatz="QNP", n_layers=4)
result = runner.run()
print(f"Energy: {result.energy:.6f} Ha  Error: {result.error:.2e}")

Live dashboard

from qmc.dashboard import start_dashboard
start_dashboard(port=8501)
# Open http://localhost:8501 — live training curves during bench.run()

Bring Your Own Data

import numpy as np
from qmc import Benchmark

X = np.random.randn(500, 6)
y = (X[:, 0] * X[:, 1] > 0).astype(int)

bench = Benchmark(dataset=(X, y), classical_methods=["RF", "MLP"])
bench.run()

Or from a CSV:

bench = Benchmark(dataset="data.csv", target_column="label")

Built-in datasets: iris, breast_cancer, wine, digits, moons, circles, blobs.

Example Output

Running examples/01_quickstart.py on Iris:

Rank Method Type Accuracy F1 Time
1 VQC quantum 1.0000 1.0000 340.7s
2 QuantumKernel quantum 0.9556 0.9554 7.8s
3 MLP classical 0.9333 0.9333 0.06s
4 SVM classical 0.9111 0.9107 0.001s
5 RF classical 0.8889 0.8878 0.03s

Examples

  • examples/01_quickstart.py — Classical vs quantum on Iris
  • examples/02_recommender.py — Get QML recommendations
  • examples/03_molecule_vqe.py — VQE on H2 (requires PySCF)
  • examples/04_custom_dataset.py — Bring your own numpy data

Run Tests

pip install -e ".[dev]"
pytest tests/

Mappings Reference

Your classical algorithm Recommended quantum counterpart
SVM Quantum Kernel SVM, VQC
MLP / Neural Net VQC, Data Re-uploading VQC
Random Forest Quantum Kernel Ensemble, VQC
Logistic Regression Quantum Kernel + Linear SVM
k-NN Quantum Kernel k-NN
XGBoost Quantum Kernel SVM, Quantum Boosted Ensemble
Naive Bayes VQC with probabilistic readout
PCA Quantum feature map, Quantum Autoencoder
anything else VQC, Quantum Kernel (general-purpose)

License

MIT — use it anywhere.

Acknowledgments

This repository was developed with AI coding assistance. The research direction, experimental design, verification, and technical decisions are original work; the code scaffolding was accelerated with Claude.

QNP gate implementation based on Anselmetti et al. (2021). Built on PennyLane and scikit-learn.

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

quantum_ml_comparator-0.2.1.tar.gz (55.4 kB view details)

Uploaded Source

Built Distribution

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

quantum_ml_comparator-0.2.1-py3-none-any.whl (54.3 kB view details)

Uploaded Python 3

File details

Details for the file quantum_ml_comparator-0.2.1.tar.gz.

File metadata

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

File hashes

Hashes for quantum_ml_comparator-0.2.1.tar.gz
Algorithm Hash digest
SHA256 8ae8290c66d9e425c89c62347edf0134adf10d54b2b94adc188860a314f220f8
MD5 7b09ae41e4500c6bc7812f0552d8fea6
BLAKE2b-256 f37f99148827249aee61147aba4e07a4af6f573bfc12a99c41b14241142a4846

See more details on using hashes here.

Provenance

The following attestation bundles were made for quantum_ml_comparator-0.2.1.tar.gz:

Publisher: release.yml on orbion-life/quantum-ml-comparator

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

File details

Details for the file quantum_ml_comparator-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for quantum_ml_comparator-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d1ce275a4e2dfc467a3a1b90a8666723aa1b9bcef29af5cafbba1fb048822876
MD5 fa3234160a80d0968d84877062dabae1
BLAKE2b-256 25c09d2ca2336494cfb9d8192a05fc2c620d24cac5bb60b8909583a190a761fb

See more details on using hashes here.

Provenance

The following attestation bundles were made for quantum_ml_comparator-0.2.1-py3-none-any.whl:

Publisher: release.yml on orbion-life/quantum-ml-comparator

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