903 MB
2,614 files
Updated 3 months ago
Ctrl+K
| Name | Size | Uploaded | Xet hash |
|---|---|---|---|
| __pycache__ | 5 items | ||
| README.md | 2.58 kB xet | 176ba191 | |
| diabetes.csv | 81.7 kB xet | a4d5ad78 | |
| generate_report_plots.py | 44.3 kB xet | 7f82a782 | |
| interpretability.py | 1.13 kB xet | 8b6398ab | |
| models.py | 1.68 kB xet | 680593f5 | |
| requirements.txt | 115 Bytes xet | 5e3a6c9a | |
| structure.md | 2.41 kB xet | 4e2cf6df | |
| tabular.py | 8.26 kB xet | 1bb69112 | |
| verify_report.py | 3.13 kB xet | aa34c7ee | |
| vision.py | 8.33 kB xet | 86352325 |
HW2/code — Detailed developer guide
This document explains the code-level entry points, how to run experiments reproducibly, and where outputs are saved.
Primary scripts & purpose
tabular.py— training pipeline for Pima diabetes dataset (downloads fallback / synthetic if offline).models.py—MLPClassifierandNAMClassifierused in experiments.interpretability.py— LIME and SHAP wrappers for per-sample explanations.vision.py— Grad-CAM, Guided Backprop, SmoothGrad, and activation maximization utilities.generate_report_plots.py— convenience script to create PNGs used in the LaTeX report.
How to reproduce the tabular baseline
Create environment and install (see
requirements.txt).Run:
cd HomeWorks/HW2/code python tabular.pytabular.pyuses localdiabetes.csvif present, otherwise attempts to download; it falls back to a deterministic synthetic dataset when offline.
Generated metrics are printed to stdout; use
generate_report_plots.pyto export figures.
Vision experiments & explanations
- The notebook
../notebooks/HW2_solution.ipynbdemonstrates how to load models, compute Grad-CAM maps, combine Guided Backprop + Grad-CAM, and run activation maximization. vision.pycontains reusable functions so you can call them programmatically from other scripts/notebooks.- Custom six-image set: to use your own images for the vision six-image analysis, pass
custom_image_paths=[...]togenerate_vision_figures()ingenerate_report_plots.py, or set the env varHW2_VISION_IMAGES(comma-separated paths or URLs). See the main HW2 README for details.
Notes on interpretability tools
- LIME/SHAP can be slow for larger datasets; use
n_samples/nsamplesparameters to limit runtime. - SHAP
KernelExplaineris model-agnostic but computationally expensive — use a small background subset for demos.
Expected outputs
report/figures/— standard plots used in the assignment report (saved bygenerate_report_plots.py).- Notebook cells include figure exports and the code used to generate them.
Troubleshooting & tips
- No internet: tabular dataset fallback ensures the notebook is runnable offline.
- Pretrained weights unavailable:
vision.pytries a non-pretrained fallback; visualizations still work but results differ.
If you want, I can add explicit CLI flags to tabular.py and vision.py for dataset path, device selection, and logging to make experiments even more reproducible.
- Total size
- 903 MB
- Files
- 2,614
- Last updated
- Sep 12
- Pre-warmed CDN
- US EU US EU