Metadata-Version: 2.4
Name: qflow-ml
Version: 0.1.0
Summary: QFlow: scikit-learn for Quantum Machine Learning
Author-email: QFlow Contributors <qflow@example.com>
License:                                  Apache License
                                   Version 2.0, January 2004
                                http://www.apache.org/licenses/
        
           TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
        
           1. Definitions.
        
              "License" shall mean the terms and conditions for use, reproduction,
              and distribution as defined by Sections 1 through 9 of this document.
        
              "Licensor" shall mean the copyright owner or entity authorized by
              the copyright owner that is granting the License.
        
              "Legal Entity" shall mean the union of the acting entity and all
              other entities that control, are controlled by, or are under common
              control with that entity. For the purposes of this definition,
              "control" means (i) the power, direct or indirect, to cause the
              direction or management of such entity, whether by contract or
              otherwise, or (ii) ownership of fifty percent (50%) or more of the
              outstanding shares, or (iii) beneficial ownership of such entity.
        
              "You" (or "Your") shall mean an individual or Legal Entity
              exercising permissions granted by this License.
        
              "Source" form shall mean the preferred form for making modifications,
              including but not limited to software source code, documentation
              source, and configuration files.
        
              "Object" form shall mean any form resulting from mechanical
              transformation or translation of a Source form, including but
              not limited to compiled object code, generated documentation,
              and conversions to other media types.
        
              "Work" shall mean the work of authorship made available under
              the License, as indicated by a copyright notice that is included in
              or attached to the work (an example is provided in the Appendix below).
        
              "Derivative Works" shall mean any work, whether in Source or Object
              form, that is based on (or derived from) the Work and for which the
              editorial revisions, annotations, elaborations, or other modifications
              represent, as a whole, an original work of authorship.
        
              "Contribution" shall mean, as submitted to the Licensor for inclusion
              in the Work by the copyright owner or by an individual or Legal Entity
              authorized to submit on behalf to the Licensor, the work of authorship
              including the original version of the Work and any modifications or
              additions to that Work or Derivative Works of the Work.
        
              "Contributor" shall mean Licensor and any Legal Entity on behalf of
              whom a Contribution has been received by the Licensor and included
              within the Work.
        
           2. Grant of Copyright License. Subject to the terms and conditions of
              this License, each Contributor hereby grants to You a perpetual,
              worldwide, non-exclusive, no-charge, royalty-free, irrevocable
              copyright license to reproduce, prepare Derivative Works of,
              publicly display, publicly perform, sublicense, and distribute the
              Work and such Derivative Works in Source or Object form.
        
           3. Grant of Patent License. Subject to the terms and conditions of
              this License, each Contributor hereby grants to You a perpetual,
              worldwide, non-exclusive, no-charge, royalty-free, irrevocable
              (except as stated in this section) patent license to make, have made,
              use, offer to sell, sell, import, and otherwise transfer the Work.
        
           4. Redistribution. You may reproduce and distribute copies of the
              Work or Derivative Works thereof in any medium, with or without
              modifications, and in Source or Object form, provided that You
              meet the following conditions:
        
              (a) You must give any other recipients of the Work or Derivative
                  Works a copy of this License; and
        
              (b) You must cause any modified files to carry prominent notices
                  stating that You changed the files; and
        
              (c) You must retain, in the Source form of any Derivative Works
                  that You distribute, all copyright, patent, trademark, and
                  attribution notices from the Source form of the Work, and
        
              (d) If the Work includes a "NOTICE" text file, include a readable
                  copy of the attribution notices contained within such NOTICE file.
        
           Copyright 2024 QFlow Contributors
        
           Licensed under the Apache License, Version 2.0 (the "License");
           you may not use this file except in compliance with the License.
           You may obtain a copy of the License at
        
               http://www.apache.org/licenses/LICENSE-2.0
        
           Unless required by applicable law or agreed to in writing, software
           distributed under the License is distributed on an "AS IS" BASIS,
           WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
           See the License for the specific language governing permissions and
           limitations under the License.
        
Project-URL: Homepage, https://github.com/qflow-ml/qflow
Project-URL: Documentation, https://qflow-ml.readthedocs.io
Project-URL: Repository, https://github.com/qflow-ml/qflow
Project-URL: Bug Tracker, https://github.com/qflow-ml/qflow/issues
Project-URL: Changelog, https://github.com/qflow-ml/qflow/blob/main/CHANGELOG.md
Keywords: quantum,machine learning,pennylane,qml,variational circuits
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Scientific/Engineering :: Physics
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pennylane>=0.36.0
Requires-Dist: autoray<0.7.0,>=0.6.11
Requires-Dist: numpy>=1.24.0
Requires-Dist: scikit-learn>=1.3.0
Requires-Dist: scipy>=1.10.0
Requires-Dist: matplotlib>=3.7.0
Provides-Extra: dev
Requires-Dist: pytest>=7.4.0; extra == "dev"
Requires-Dist: pytest-cov>=4.1.0; extra == "dev"
Requires-Dist: ruff>=0.1.0; extra == "dev"
Requires-Dist: mypy>=1.5.0; extra == "dev"
Requires-Dist: pre-commit>=3.4.0; extra == "dev"
Provides-Extra: docs
Requires-Dist: mkdocs>=1.5.0; extra == "docs"
Requires-Dist: mkdocs-material>=9.0.0; extra == "docs"
Requires-Dist: mkdocstrings[python]>=0.23.0; extra == "docs"
Dynamic: license-file

<h1 align="center">
  <br>
  ⚛️ QFlow
  <br>
</h1>

<h4 align="center">
  <em>scikit-learn for Quantum Machine Learning</em>
</h4>

<p align="center">
  <a href="https://github.com/qflow-ml/qflow/actions/workflows/ci.yml">
    <img src="https://github.com/qflow-ml/qflow/actions/workflows/ci.yml/badge.svg" alt="CI">
  </a>
  <a href="https://pypi.org/project/qflow-ml/">
    <img src="https://img.shields.io/pypi/v/qflow-ml" alt="PyPI">
  </a>
  <a href="https://img.shields.io/pypi/pyversions/qflow-ml">
    <img src="https://img.shields.io/pypi/pyversions/qflow-ml" alt="Python">
  </a>
  <a href="https://opensource.org/licenses/Apache-2.0">
    <img src="https://img.shields.io/badge/License-Apache%202.0-blue.svg" alt="License">
  </a>
  <a href="https://codecov.io/gh/qflow-ml/qflow">
    <img src="https://codecov.io/gh/qflow-ml/qflow/branch/main/graph/badge.svg" alt="Coverage">
  </a>
</p>

---

**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

```python
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

```bash
pip install qflow-ml
```

**From source:**

```bash
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

```python
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

```python
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

```python
from qflow import Transformer

transformer = Transformer(n_components=2)
X_reduced = transformer.fit_transform(X_train)
```

### Scikit-learn Integration

```python
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

```python
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

```python
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

```python
model = Classifier(strategy="one_vs_rest")   # OvR decomposition
model.fit(X_train, y_train)                  # y_train can have > 2 classes
```

## 🤝 Contributing

See [CONTRIBUTING.md](CONTRIBUTING.md). All contributions welcome!

```bash
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](LICENSE).

## 🔗 Related Work

- [PennyLane](https://pennylane.ai/) — Differentiable quantum computing
- [Qiskit Machine Learning](https://qiskit-community.github.io/qiskit-machine-learning/)
- [TensorFlow Quantum](https://www.tensorflow.org/quantum)
