⚛️ QFlow
scikit-learn for Quantum Machine Learning
QFlow is an open-source Python framework that makes quantum machine learning as easy as scikit-learn. All quantum complexity — qubits, circuits, gates, encodings, ansatz, optimizers, and backends — is handled automatically. You focus on your ML problem.
✨ Quickstart
from qflow import Classifier
model = Classifier()
model.fit(X_train, y_train)
predictions = model.predict(X_test)
accuracy = model.score(X_test, y_test)
That's it. No quantum knowledge required.
📦 Installation
pip install qflow-ml
From source:
git clone https://github.com/qflow-ml/qflow.git
cd qflow
pip install -e ".[dev]"
🔬 Features
| Feature | Description |
|---|---|
| Auto-configuration | Automatically selects qubits, encoding, ansatz, and optimizer |
| Scikit-learn API | Drop-in replacement for classical estimators |
| Multiple encodings | Angle, Amplitude, IQP feature maps |
| Variational ansatz | Strongly Entangling, Hardware Efficient, Basic Entangler |
| Flexible optimizers | Adam, COBYLA, Adagrad, RMSProp, NesterovMomentum |
| Backend agnostic | PennyLane (default), Qiskit (planned) |
| Visualization | Circuit plots, training curves |
| sklearn compatible | Works with GridSearchCV, Pipeline, cross_val_score |
📖 Examples
Classification
from qflow import Classifier
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
X, y = load_iris(return_X_y=True)
# Use 2 classes for binary classification
mask = y < 2
X, y = X[mask], y[mask]
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)
scaler = StandardScaler()
X_train = scaler.fit_transform(X_train)
X_test = scaler.transform(X_test)
model = Classifier(n_layers=3, optimizer="adam", max_iter=100)
model.fit(X_train, y_train)
print(f"Accuracy: {model.score(X_test, y_test):.2%}")
Regression
from qflow import Regressor
import numpy as np
X = np.linspace(0, 2*np.pi, 80).reshape(-1, 1)
y = np.sin(X).ravel()
reg = Regressor()
reg.fit(X[:60], y[:60])
preds = reg.predict(X[60:])
Dimensionality Reduction
from qflow import Transformer
transformer = Transformer(n_components=2)
X_reduced = transformer.fit_transform(X_train)
Scikit-learn Integration
from sklearn.pipeline import Pipeline
from sklearn.preprocessing import StandardScaler
from sklearn.model_selection import GridSearchCV
from qflow import Classifier
pipe = Pipeline([
("scaler", StandardScaler()),
("qclf", Classifier()),
])
param_grid = {"qclf__n_layers": [1, 2, 3], "qclf__optimizer": ["adam", "cobyla"]}
grid = GridSearchCV(pipe, param_grid, cv=3)
grid.fit(X_train, y_train)
Visualization
from qflow import Classifier
from qflow.visualization import plot_training_history, plot_circuit
model = Classifier()
model.fit(X_train, y_train)
plot_training_history(model) # Loss/accuracy curves
plot_circuit(model) # Circuit diagram
🏗️ Architecture
qflow/
├── Classifier ← Public API
├── Regressor ← Public API
├── Transformer ← Public API
├── core/
│ ├── auto_config ← Automatic hyperparameter selection
│ ├── circuit_builder← PennyLane circuit construction
│ ├── optimizer ← Optimizer factory
│ └── measurement ← Measurement strategies
├── encodings/ ← Angle, Amplitude, IQP
├── ansatz/ ← StronglyEntangling, HardwareEfficient, BasicEntangler
├── backends/ ← PennyLane (default), Qiskit (planned)
└── visualization/ ← Training plots, circuit diagrams
🔧 Advanced Usage
Custom configuration
from qflow import Classifier
from qflow.encodings import AmplitudeEncoding
from qflow.ansatz import HardwareEfficientAnsatz
from qflow.backends import PennyLaneBackend
model = Classifier(
encoding="amplitude",
ansatz="hardware_efficient",
n_layers=4,
optimizer="adam",
learning_rate=0.01,
max_iter=200,
backend="pennylane",
random_state=42,
)
model.fit(X_train, y_train)
Multiclass classification
model = Classifier(strategy="one_vs_rest") # OvR decomposition
model.fit(X_train, y_train) # y_train can have > 2 classes
🤝 Contributing
See CONTRIBUTING.md. All contributions welcome!
git clone https://github.com/qflow-ml/qflow.git
cd qflow
pip install -e ".[dev]"
pre-commit install
pytest
📄 License
Apache 2.0 — see LICENSE.
🔗 Related Work
- PennyLane — Differentiable quantum computing
- Qiskit Machine Learning
- TensorFlow Quantum
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 qflow_ml-0.1.0.tar.gz.
File metadata
- Download URL: qflow_ml-0.1.0.tar.gz
- Upload date:
- Size: 39.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0ee839b09bd1e6b0ea15e34ae21ee260e730cc086ffa327a1adaf2aa830e1d59
|
|
| MD5 |
20c346297bcbace46b637960fa2bf448
|
|
| BLAKE2b-256 |
6379557c5443bcb97c826220f5fbf122392ae813aaeb0e6698d9f322247ce086
|
Provenance
The following attestation bundles were made for qflow_ml-0.1.0.tar.gz:
Publisher:
publish.yml on azeemiqbal321/QFlow
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
qflow_ml-0.1.0.tar.gz -
Subject digest:
0ee839b09bd1e6b0ea15e34ae21ee260e730cc086ffa327a1adaf2aa830e1d59 - Sigstore transparency entry: 2340962956
- Sigstore integration time:
-
Permalink:
azeemiqbal321/QFlow@d6e8295b845c0b6d92d36ee20469e024e6ba025d -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/azeemiqbal321
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d6e8295b845c0b6d92d36ee20469e024e6ba025d -
Trigger Event:
push
-
Statement type:
File details
Details for the file qflow_ml-0.1.0-py3-none-any.whl.
File metadata
- Download URL: qflow_ml-0.1.0-py3-none-any.whl
- Upload date:
- Size: 47.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e420fd70e25a498bbf86e8db7dd63ef4a09f170a87ab25b6def784757d571e64
|
|
| MD5 |
b47a227da59850db48903417c79557f9
|
|
| BLAKE2b-256 |
921205debdd865ce331635184b8dee5f3b41b9acfa8804ccbe9f1e6efd4f43b5
|
Provenance
The following attestation bundles were made for qflow_ml-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on azeemiqbal321/QFlow
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
qflow_ml-0.1.0-py3-none-any.whl -
Subject digest:
e420fd70e25a498bbf86e8db7dd63ef4a09f170a87ab25b6def784757d571e64 - Sigstore transparency entry: 2340962972
- Sigstore integration time:
-
Permalink:
azeemiqbal321/QFlow@d6e8295b845c0b6d92d36ee20469e024e6ba025d -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/azeemiqbal321
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d6e8295b845c0b6d92d36ee20469e024e6ba025d -
Trigger Event:
push
-
Statement type: