Skip to main content

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


Download files

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

Source Distribution

qml_oncology-0.1.0.tar.gz (35.7 kB view details)

Uploaded Source

Built Distribution

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

qml_oncology-0.1.0-py3-none-any.whl (52.7 kB view details)

Uploaded Python 3

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

Hashes for qml_oncology-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9d3804366ffee1796969af57b21c07003c40b66fa88b9e61508f8123c86c2c71
MD5 621b7e2825b54a44395b914633ef9113
BLAKE2b-256 5b948e0fe5134114d3887dd4c83ae4984e7d81865d2a0b9b952e763f39e44349

See more details on using hashes here.

Provenance

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

Publisher: publish.yml on KMaruthi2002/QuanTriage

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

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

Hashes for qml_oncology-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d196c1cead33ed835e64c808ab381bbf730d4fa5e8e21688233be1f4b9a5f751
MD5 18088a161f9fe152449d33bd28c7bc84
BLAKE2b-256 d27de3833e11e9477b34f6c05633da5d9eb69b5889415d21a3992f674177f3d0

See more details on using hashes here.

Provenance

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

Publisher: publish.yml on KMaruthi2002/QuanTriage

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

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page