The hands-on code companion to Modules 5 through 12. Every notebook is a real, executed Jupyter notebook — run it as-is, open it directly in Google Colab with zero setup, or download it and adapt it into your own Module 12 final project.
# run this first in Colab
!pip install pennylane qiskit qiskit-aer \
scikit-learn matplotlib numpy --quiet
Shift + Enter.python3 --version.python3 -m venv qml-env # macOS / Linux source qml-env/bin/activate # Windows qml-env\Scripts\activate
pip install pennylane qiskit qiskit-aer \
scikit-learn matplotlib numpy jupyter
jupyter notebook
| Library | Used for | Install |
|---|---|---|
| pennylane | Quantum circuits, autodiff, QML training (Notebooks 02–08) | pip install pennylane |
| qiskit | Circuit basics, Bloch sphere, statevectors (Notebook 01, 06) | pip install qiskit |
| qiskit-aer | Simulator backend + noise models (Notebook 01, 06) | pip install qiskit-aer |
| scikit-learn | Datasets, classical SVM/logistic regression baselines, PCA | pip install scikit-learn |
| matplotlib | All plots and visualizations | pip install matplotlib |
| numpy | Array math throughout every notebook | pip install numpy |
| jupyter | Only needed for Option B (local); Colab already has it | pip install jupyter |
All commands above install the same set of packages — pennylane, qiskit, qiskit-aer, scikit-learn, matplotlib, numpy — Option B adds jupyter since Colab already includes it.
Run cells top to bottom. Later cells reuse variables defined earlier — skipping around out of order will throw NameError.
Training cells take time. Notebooks 03, 05, 07 & 08 include real training loops — anywhere from a few seconds to ~1–2 minutes per cell is normal for a quantum simulator.
Numbers may vary slightly. Every notebook uses a fixed random seed, but tiny differences across library versions (PennyLane/Qiskit updates) are normal and don't indicate a broken notebook.
Built and tested with: PennyLane 0.45, Qiskit 2.5, scikit-learn 1.8, NumPy 2.4. Newer versions should work fine; if something breaks, pinning to these versions is a safe fallback.
Build single- and multi-qubit circuits in Qiskit. Apply gates, read statevectors, visualize the Bloch sphere, simulate the Born rule, and build your first entangled Bell pair.
Implement basis, angle, and amplitude encoding in PennyLane, build a ZZ-style feature map, and see data re-uploading squeeze expressivity from a single qubit.
Verify the parameter-shift rule by hand, then train a full Quantum Neural Network classifier on the moons dataset and visualize its decision boundary.
Build a quantum kernel from scratch, feed it into a classical SVM, and benchmark it head-to-head against linear and RBF kernels — plus a quantum-kernel PCA projection.
Build a Quantum Convolutional Neural Network with real conv + pooling layers, then train a minimal quantum generator against a quantum discriminator — including an honest look at why adversarial training is hard to stabilize.
Add a realistic Qiskit Aer noise model, then implement readout error mitigation via a calibration matrix and Zero-Noise Extrapolation via gate folding.
Two full case studies: a QSVM diagnosing real breast cancer data, and a QNN predicting synthetic price direction — including an honest contrast between a learnable momentum market and pure random-walk noise.
The full pipeline template: define → preprocess → encode → train → evaluate → compare, applied to handwritten digit classification — plus copy-paste-ready templates for running your circuits on real IBM Quantum hardware.