Skip to main content


⚛️ QFlow

scikit-learn for Quantum Machine Learning

CI PyPI Python License Coverage


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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

qflow_ml-0.1.0.tar.gz (39.7 kB view details)

Uploaded Source

Built Distribution

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

qflow_ml-0.1.0-py3-none-any.whl (47.3 kB view details)

Uploaded Python 3

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

Hashes for qflow_ml-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0ee839b09bd1e6b0ea15e34ae21ee260e730cc086ffa327a1adaf2aa830e1d59
MD5 20c346297bcbace46b637960fa2bf448
BLAKE2b-256 6379557c5443bcb97c826220f5fbf122392ae813aaeb0e6698d9f322247ce086

See more details on using hashes here.

Provenance

The following attestation bundles were made for qflow_ml-0.1.0.tar.gz:

Publisher: publish.yml on azeemiqbal321/QFlow

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

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

Hashes for qflow_ml-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e420fd70e25a498bbf86e8db7dd63ef4a09f170a87ab25b6def784757d571e64
MD5 b47a227da59850db48903417c79557f9
BLAKE2b-256 921205debdd865ce331635184b8dee5f3b41b9acfa8804ccbe9f1e6efd4f43b5

See more details on using hashes here.

Provenance

The following attestation bundles were made for qflow_ml-0.1.0-py3-none-any.whl:

Publisher: publish.yml on azeemiqbal321/QFlow

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

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page