quantum-learn: quantum machine learning in Python
Project description
quantum-learn
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.QuantumFeatureMapandqlearn.qiskit.QuantumFeatureMap - A generic
VariationalQuantumCircuitwith configurable measurement and loss settings - Task-oriented
VariationalQuantumClassifierandVariationalQuantumRegressorwrappers with sensible defaults - Hybrid estimators for classification, regression, and clustering on top of quantum feature maps
- Optional backend dependencies so importing
qlearndoes not require every quantum framework - A default top-level backend for users who want a simple
qlearn.QuantumFeatureMap()orqlearn.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.pennylaneexposes the implemented Pennylane backend.qlearn.qiskitcurrently exposes the QiskitQuantumFeatureMap.- The top-level
qlearn.QuantumFeatureMapandqlearn.VariationalQuantumCircuitresolve to the default backend, which is currently Pennylane. qlearn.qiskit.VariationalQuantumCircuitis 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. Usefit_predict()when you want clustering in a single call.VariationalQuantumClassifierdefaults to probability outputs and cross-entropy training, with automatic label encoding andpredict_proba().VariationalQuantumRegressordefaults to expectation-value outputs and MSE training, with automatic target scaling and inverse-scaling at prediction time.VariationalQuantumCircuitnow supports configurablemeasurement,measurement_wires, andlossvalues infit().- 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:
- Fork the repository
- Create a new branch (feature-branch)
- 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
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 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b31b98cf5828c48a0bc75e1f572600739245a19cef80b4c6409aa0f2cbbeb66f
|
|
| MD5 |
a9c681c0f91dbe4b6638633517b4a375
|
|
| BLAKE2b-256 |
88a978bf25cc0269cd13e027c3713bb9f60497c40b947b6913a6ad552a5ef50f
|
Provenance
The following attestation bundles were made for quantum_learn-2.0.0.tar.gz:
Publisher:
package.yml on OsamaMIT/quantum-learn
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
quantum_learn-2.0.0.tar.gz -
Subject digest:
b31b98cf5828c48a0bc75e1f572600739245a19cef80b4c6409aa0f2cbbeb66f - Sigstore transparency entry: 1236490111
- Sigstore integration time:
-
Permalink:
OsamaMIT/quantum-learn@0ad4db20fcc549eed43641537f3c072361d0ff90 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/OsamaMIT
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
package.yml@0ad4db20fcc549eed43641537f3c072361d0ff90 -
Trigger Event:
workflow_dispatch
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ee0cd7aed2a4c5787b9bbe26bc911f0912be33a5100e3aac5bd98e7b04f79bc3
|
|
| MD5 |
f487d4cd54fe956d1c6e810067dbd504
|
|
| BLAKE2b-256 |
44d84eec906b1f2ad22f4780b2ca218db15bd3a27170e6326a4e7783607e0ae5
|
Provenance
The following attestation bundles were made for quantum_learn-2.0.0-py3-none-any.whl:
Publisher:
package.yml on OsamaMIT/quantum-learn
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
quantum_learn-2.0.0-py3-none-any.whl -
Subject digest:
ee0cd7aed2a4c5787b9bbe26bc911f0912be33a5100e3aac5bd98e7b04f79bc3 - Sigstore transparency entry: 1236490126
- Sigstore integration time:
-
Permalink:
OsamaMIT/quantum-learn@0ad4db20fcc549eed43641537f3c072361d0ff90 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/OsamaMIT
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
package.yml@0ad4db20fcc549eed43641537f3c072361d0ff90 -
Trigger Event:
workflow_dispatch
-
Statement type: