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.
- 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
Base install:
pip install quantum-learnThe 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]"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.
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.
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.
For tutorials, examples, and details on the classes, check out the quantum-learn documentation.
If you're working with the source, the required dependencies can be installed by
pip install -r requirements.txt- Implement quantum kernel methods
- Implement categorical feature maps
Contributions are welcome! To contribute:
- Fork the repository
- Create a new branch (feature-branch)
- Commit your changes and open a pull request
This project is licensed under the MIT License. See LICENSE for details.