Quantum machine learning + medical imaging for oncology: clinically-honest classifiers, multi-cancer typing, and tumor localization.
Project description
qml-oncology
Quantum machine learning + medical imaging for oncology. Reusable, clinically-honest formulations: variational quantum classifiers (swappable encodings and simulator / real-hardware backends), a multi-cancer-type classifier, a selective-prediction / cost-sensitive evaluation toolkit, a radiomics-to-quantum bridge, and U-Net tumor localization with 3-D rendering.
Extracted from the QuanTriage project so others can build on the same methods.
Educational / research software. Not a validated medical device.
Install
pip install qml-oncology # core: quantum classifiers + eval toolkit + datasets
pip install qml-oncology[imaging] # + U-Nets, radiomics, 3-D rendering (torch, nibabel, ...)
pip install qml-oncology[hardware] # + IBM Quantum via pennylane-qiskit
pip install qml-oncology[all] # everything
Quick start
A clinically-honest quantum classifier
from sklearn.datasets import load_breast_cancer
from sklearn.model_selection import train_test_split
from qml_oncology import (FlexibleQuantumClassifier, compute_metrics,
cost_sensitive_threshold, selective_prediction)
X, y = load_breast_cancer(return_X_y=True)
y = (y == 0).astype(int) # positive class = malignant
Xtr, Xte, ytr, yte = train_test_split(X[:, :6], y, stratify=y, random_state=0)
clf = FlexibleQuantumClassifier(encoding="reupload", n_qubits=6, n_layers=4, epochs=25)
clf.fit(Xtr, ytr)
proba = clf.predict_proba(Xte)[:, 1]
# tune a threshold that treats a missed cancer as 10x worse than a false alarm
thr = cost_sensitive_threshold(yte, proba, cost_ratio=10)
print(compute_metrics(yte, proba, thr)) # accuracy, sensitivity, specificity, AUC, ...
# defer low-confidence cases to a human instead of guessing
print(selective_prediction(yte, proba, confidence=0.85))
Encodings, bigger models, real hardware
# data re-uploading or amplitude encoding, on the fast C++ simulator
m = FlexibleQuantumClassifier(encoding="amplitude", n_qubits=4, device="lightning.qubit")
# train on a simulator, then run the SAME trained circuit on real hardware
from qml_oncology import make_device # device factory
m.predict_on_device(Xte, "qiskit.remote", shots=1024) # IBM Quantum (needs your token)
m.predict_on_device(Xte, "braket.aws.qubit", shots=1024) # AWS Braket (needs AWS creds)
Multi-cancer typing (5 tumor types from gene expression)
from qml_oncology import load_dataset, MultiClassQuantumClassifier
ds = load_dataset("pan_cancer_rnaseq", n_features=10) # downloads TCGA data on first use
clf = MultiClassQuantumClassifier(n_classes=ds.n_classes, n_qubits=10, epochs=35).fit(ds.X_train, ds.y_train)
Imaging (needs [imaging]): tumor localization + 3-D render
from qml_oncology.segmentation.multimodal import build_multimodal_dataset, train_multimodal
from qml_oncology.imaging.tumor3d import build_figure # interactive 3-D tumor render
from qml_oncology.imaging.bridge import radiomics_vector # radiomics -> quantum circuit
What's inside
| Module | What |
|---|---|
qml_oncology.quantum |
variational, multi-class, flexible (encodings + backends), and PyTorch hybrid classifiers |
qml_oncology.evaluation |
cost-sensitive thresholding, selective prediction, noise robustness, permutation importance |
qml_oncology.data |
dataset registry (breast cancer, TCGA pan-cancer RNA-seq) |
qml_oncology.imaging |
radiomics, 3-D rendering, radiomics-to-quantum bridge |
qml_oncology.segmentation |
2-D / 3-D U-Nets, multi-modal MRI loaders, training |
Full app, visuals, and docs: https://github.com/KMaruthi2002/QuanTriage
License
MIT
Project details
Release history Release notifications | RSS feed
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 qml_oncology-0.1.0.tar.gz.
File metadata
- Download URL: qml_oncology-0.1.0.tar.gz
- Upload date:
- Size: 35.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9d3804366ffee1796969af57b21c07003c40b66fa88b9e61508f8123c86c2c71
|
|
| MD5 |
621b7e2825b54a44395b914633ef9113
|
|
| BLAKE2b-256 |
5b948e0fe5134114d3887dd4c83ae4984e7d81865d2a0b9b952e763f39e44349
|
Provenance
The following attestation bundles were made for qml_oncology-0.1.0.tar.gz:
Publisher:
publish.yml on KMaruthi2002/QuanTriage
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
qml_oncology-0.1.0.tar.gz -
Subject digest:
9d3804366ffee1796969af57b21c07003c40b66fa88b9e61508f8123c86c2c71 - Sigstore transparency entry: 1900732110
- Sigstore integration time:
-
Permalink:
KMaruthi2002/QuanTriage@a77ee26ba1693f06c7244e8b6e5a291638c4fdb5 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/KMaruthi2002
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a77ee26ba1693f06c7244e8b6e5a291638c4fdb5 -
Trigger Event:
release
-
Statement type:
File details
Details for the file qml_oncology-0.1.0-py3-none-any.whl.
File metadata
- Download URL: qml_oncology-0.1.0-py3-none-any.whl
- Upload date:
- Size: 52.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d196c1cead33ed835e64c808ab381bbf730d4fa5e8e21688233be1f4b9a5f751
|
|
| MD5 |
18088a161f9fe152449d33bd28c7bc84
|
|
| BLAKE2b-256 |
d27de3833e11e9477b34f6c05633da5d9eb69b5889415d21a3992f674177f3d0
|
Provenance
The following attestation bundles were made for qml_oncology-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on KMaruthi2002/QuanTriage
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
qml_oncology-0.1.0-py3-none-any.whl -
Subject digest:
d196c1cead33ed835e64c808ab381bbf730d4fa5e8e21688233be1f4b9a5f751 - Sigstore transparency entry: 1900732431
- Sigstore integration time:
-
Permalink:
KMaruthi2002/QuanTriage@a77ee26ba1693f06c7244e8b6e5a291638c4fdb5 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/KMaruthi2002
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a77ee26ba1693f06c7244e8b6e5a291638c4fdb5 -
Trigger Event:
release
-
Statement type: