Original repository by Matthew Maccelari
In this repository, quantum-enhanced support vector machines (QSVMs) are explored by embedding classical data into a high-dimensional Hilbert space via a parameterised quantum feature map and comparing performance against a classical RBF-kernel SVM. The programs:
- Clean and preprocess a binary classification dataset.
- Reduce dimensionality with PCA.
- Train and evaluate a QSVM on both a statevector simulator and real IBM quantum hardware.
- Benchmark accuracy and runtime against a classical SVM baseline.
- Visualise quantum kernel matrices as heatmaps.
Quantum-Machine-Learning-REUPLOAD/
├── README.md
├── .env ← pinned package versions
├── src/
│ ├── simulatorQML.ipynb ← QSVM on Qiskit statevector simulator
│ └── hardwareQML.ipynb ← QSVM on IBM quantum hardware
├── Heatmaps/
│ └── kernel_*.png ← Saved quantum-kernel heatmaps
└── Dataset/
└── bots_vs_users.csv ← Raw binary-classification dataset
- Python 3.8+
pandasnumpyscikit-learnmatplotlib- Qiskit stack (exact versions)
pip install \ qiskit==1.4.3 \ qiskit-aer==0.11.0 \ qiskit-ibm-runtime==0.13.1 \ qiskit-machine-learning==0.8.2
-
Clone the repo
git clone https://github.com/your-repo/ELEN4022_LAB3_2025_MATTHEW_MACCELARI.git cd ELEN4022_LAB3_2025_MATTHEW_MACCELARI -
Install dependencies Create and activate the Conda environment from
environment.yml:
conda env create -f environment.yml
conda activate elen4022_lab3
3. **Configure IBM Quantum credentials**
```bash
export IBMQ_TOKEN="YOUR_IBM_QUANTUM_API_TOKEN"or run QiskitRuntimeService.save_account(…) in a Python REPL.
Open and run:
jupyter notebook src/simulatorQML.ipynbThis notebook:
- Loads & cleans
Dataset/bots_vs_users.csv - Applies variance filtering and PCA
- Trains QSVM with
ZZFeatureMap + FidelityStatevectorKernelon a statevector simulator - Trains a classical RBF-kernel SVM baseline
- Records accuracies and saves kernel-matrix heatmaps to
Heatmaps/
Open and run:
jupyter notebook src/hardwareQML.ipynbThis notebook follows the same preprocessing pipeline, then:
- Builds a 1-repetition
ZZFeatureMapcircuit on$n$ qubits. - Uses
QiskitRuntimeService&SamplerV2to dispatch fidelity-circuit jobs to the least-busy IBM quantum backend. - Computes Gram matrices from measurement probabilities of
$\lvert0\cdots0\rangle$ . - Trains a classical SVM with
kernel='precomputed'on the real-device kernel. - Prints test accuracy and optionally visualises the train-kernel heatmap.
Note: Real-device runs can take several minutes and incur queue times.
-
Heatmaps:
Heatmaps/kernel_n{n}_size{m}.pngshowing quantum kernel matrices for each PCA dimension$n$ and sample size$m$ . - Accuracy tables: Displayed in both notebooks, comparing QSVM vs classical SVM across experimental conditions.