Skip to main content

quantum-learn: quantum machine learning in Python

Project description

quantum-learn

PyPI Version License Python Versions

quantum-learn is a quantum machine learning library with backend-specific APIs for Pennylane and Qiskit, plus higher-level estimators and VQC wrappers for common workflows.

Features

  • Backend-specific entry points such as qlearn.pennylane.QuantumFeatureMap and qlearn.qiskit.QuantumFeatureMap
  • A generic VariationalQuantumCircuit with configurable measurement and loss settings
  • Task-oriented VariationalQuantumClassifier and VariationalQuantumRegressor wrappers with sensible defaults
  • Hybrid estimators for classification, regression, and clustering on top of quantum feature maps
  • Optional backend dependencies so importing qlearn does not require every quantum framework
  • A default top-level backend for users who want a simple qlearn.QuantumFeatureMap() or qlearn.VariationalQuantumCircuit() entry point

Installation

Base install:

pip install quantum-learn

The base install is enough to import the package and use backend-independent utilities, but any quantum execution requires at least one backend extra.

Install with a specific backend:

pip install "quantum-learn[pennylane]"
pip install "quantum-learn[qiskit]"

Install both backends:

pip install "quantum-learn[all]"

Install from source:

git clone https://github.com/OsamaMIT/quantum-learn.git
cd quantum-learn
pip install -e ".[pennylane]"

Backend Model

  • qlearn.pennylane exposes the implemented Pennylane backend.
  • qlearn.qiskit currently exposes the Qiskit QuantumFeatureMap.
  • The top-level qlearn.QuantumFeatureMap and qlearn.VariationalQuantumCircuit resolve to the default backend, which is currently Pennylane.
  • qlearn.qiskit.VariationalQuantumCircuit is intentionally not exported yet because it is not implemented.

Usage

Use a backend directly:

from qlearn.pennylane import QuantumFeatureMap

qfm = QuantumFeatureMap()
transformed = qfm.transform(data)

Use a hybrid estimator with an explicit backend:

from qlearn import HybridClassification

model = HybridClassification(backend="pennylane")
model.fit(features, labels)
predictions = model.predict(features)

Use clustering with a sklearn-style workflow:

from qlearn import HybridClustering

clusterer = HybridClustering(backend="pennylane")
labels = clusterer.fit_predict(features, n_clusters=3)

Use a task wrapper on top of the shared VQC:

from qlearn import VariationalQuantumClassifier, VariationalQuantumRegressor

classifier = VariationalQuantumClassifier()
classifier.fit(features, labels)
predictions = classifier.predict(features)
probabilities = classifier.predict_proba(features)

regressor = VariationalQuantumRegressor()
regressor.fit(features, targets)
values = regressor.predict(features)

Or use the generic VQC directly with explicit output and loss choices:

from qlearn import VariationalQuantumCircuit

vqc = VariationalQuantumCircuit()
vqc.fit(
    features,
    labels,
    measurement="probabilities",
    loss="cross_entropy",
)
raw_outputs = vqc.predict(features)

You can also override the task defaults by supplying custom target encoders, prediction decoders, probability decoders, ansatz functions, or fit-time VQC options.

API Notes

  • fit() is the primary training method. train() remains available as an alias for compatibility.
  • HybridClustering.predict() now requires a fitted model. Use fit_predict() when you want clustering in a single call.
  • VariationalQuantumClassifier defaults to probability outputs and cross-entropy training, with automatic label encoding and predict_proba().
  • VariationalQuantumRegressor defaults to expectation-value outputs and MSE training, with automatic target scaling and inverse-scaling at prediction time.
  • VariationalQuantumCircuit now supports configurable measurement, measurement_wires, and loss values in fit().
  • Both wrappers still accept custom target encoders and decoders when you want full control.

Documentation

For tutorials, examples, and details on the classes, check out the quantum-learn documentation.

Dependencies

If you're working with the source, the required dependencies can be installed by

pip install -r requirements.txt

Planned Features

  • Implement quantum kernel methods
  • Implement categorical feature maps

Contributing

Contributions are welcome! To contribute:

  1. Fork the repository
  2. Create a new branch (feature-branch)
  3. Commit your changes and open a pull request

License

This project is licensed under the MIT License. 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

quantum_learn-2.0.0.tar.gz (18.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_learn-2.0.0-py3-none-any.whl (19.2 kB view details)

Uploaded Python 3

File details

Details for the file quantum_learn-2.0.0.tar.gz.

File metadata

  • Download URL: quantum_learn-2.0.0.tar.gz
  • Upload date:
  • Size: 18.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for quantum_learn-2.0.0.tar.gz
Algorithm Hash digest
SHA256 b31b98cf5828c48a0bc75e1f572600739245a19cef80b4c6409aa0f2cbbeb66f
MD5 a9c681c0f91dbe4b6638633517b4a375
BLAKE2b-256 88a978bf25cc0269cd13e027c3713bb9f60497c40b947b6913a6ad552a5ef50f

See more details on using hashes here.

Provenance

The following attestation bundles were made for quantum_learn-2.0.0.tar.gz:

Publisher: package.yml on OsamaMIT/quantum-learn

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_learn-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: quantum_learn-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 19.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for quantum_learn-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ee0cd7aed2a4c5787b9bbe26bc911f0912be33a5100e3aac5bd98e7b04f79bc3
MD5 f487d4cd54fe956d1c6e810067dbd504
BLAKE2b-256 44d84eec906b1f2ad22f4780b2ca218db15bd3a27170e6326a4e7783607e0ae5

See more details on using hashes here.

Provenance

The following attestation bundles were made for quantum_learn-2.0.0-py3-none-any.whl:

Publisher: package.yml on OsamaMIT/quantum-learn

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