Qubit_Minds: Using Quantum Neural Networks to diagnose to malignant breast cancer tumors
<title>Hybrid Quantum–Classical Classification</title>This Jupyter notebook implements and compares three classifiers—classical-only, quantum-only, and hybrid quantum–classical—on two biomedical datasets. It demonstrates end-to-end training, explainability, adversarial robustness, human-in-the-loop validation, and governance-style metadata logging.
- File:
wdbc.data - Source: UCI Machine Learning Repository
- Placement: Notebook’s working directory
- Files:
DIA_trainingset.csv,DIA_testset.csv - Source: UCI Machine Learning Repository
- Placement: Same folder as
Hybrid_Model.ipynb
Create a Python 3 environment and install dependencies:
pip install torch pennylane scikit-learn pandas matplotlib shap cryptographyIn the notebook, choose the dataset by setting:
# 1 = Breast Cancer, 2 = Drug-Induced Autoimmunity
DATASET = 1
The number of qubits (n_qubits) adjusts automatically based on the chosen dataset along with number of other internal parameters which adjust based on the differing dimensionality and size of the two datasets
- Open
Hybrid_Model.ipynbin JupyterLab or Jupyter Notebook. - Run cells in order:
- Data preprocessing
- Circuit & model definitions
- Training & evaluation
- Explainability, adversarial analysis, counterfactuals
- Human-in-the-loop hooks & governance logging
A three-layer feedforward PyTorch network.
Angle embedding → PennyLane TorchLayer with entanglers → linear readout.
Classical feature extractor → quantum state regressor → skip-connection to final head.
- SHAP Interpretability
Visualize feature contributions via SHAP. - Adversarial Bounds
Compute trace-distance bounds; plot robustness vs. perturbation. - Counterfactual Generation
Gradient-based minimal perturbations to flip predictions. - Human-in-the-Loop
Prompts for user approval or override of model outputs. - Encryption & Governance
CSV encryption utilities and JSON metadata logging for audits.
On Dataset 1, the hybrid model achieved an ~2 percentage-point improvement in test accuracy over the classical baseline. Detailed metrics (precision, recall, F1), confusion matrices, and plots are provided in the notebook.
- PennyLane documentation
- SHAP library
- UCI Machine Learning Repository for datasets
- A Variational Algorithm for Quantum Neural Networks
- Course on Quantum Variational Algorithm Design
- Survey on works done in VQAs over the past decade
Contributors (CMU Quantum Enthusiasts): Viraj Shah (virajs@andrew.cmu.edu) Kamya Singh (kamyas@andrew.cmu.edu) Mohammed Rajkotwala (mrajkotw@andrew.cmu.edu)