903 MB
2,614 files
Updated about 2 months ago
Ctrl+K
| Name | Size | Uploaded | Xet hash |
|---|---|---|---|
| code | 176 items | ||
| dataset | 4 items | ||
| description | 2 items | ||
| exps | 2 items | ||
| models | 2 items | ||
| output | 15 items | ||
| report | 27 items | ||
| scripts | 2 items | ||
| zip file | 1 items | ||
| .DS_Store | 12.3 kB xet | 02bf235c | |
| README.md | 2.96 kB xet | 8efec18a |
HW3 — Causal Recourse (full-code + notebook)
This homework implements structural causal modeling, actionability constraints, and multiple recourse algorithms with evaluation on real datasets (Adult, COMPAS, Health, Loan).
High-level summary
- Objective: produce actionable recourse (minimal-cost interventions) under actionability constraints and evaluate validity under causal models.
- Implemented recourse: linear constrained recourse, differentiable (gradient-based) recourse, and causal counterfactual evaluation via SCMs.
Important locations
dataset/— place or extract the health data asdataset/diabetes.csv(or setHW3_HEALTH_DATAto your CSV path).code/q5_codes/— core implementation (training, SCMs, recourse algorithms, evaluation).code/HW3_complete_assignment.ipynb— full notebook covering Q1–Q6 and report artifact generation.models/(top-level) — pre-trained model weights included for quick evaluation.results/— CSV / .npy outputs from previous runs (validity/cost profiles).
Quick start (run the Q5 pipeline)
cd HomeWorks/HW3/code/q5_codes
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
python main.py --seed 0
- Use
--dataset health|adult|loan|compaswhere supported by the script flags. - Save/load models are written under
models/and evaluation artifacts underresults/. - Q3 (airline): The notebook uses provided airline data if a CSV with the expected columns exists in
dataset/; otherwise it uses a synthetic SCM-based dataset so all Q3 parts run. To generate a reusable synthetic file:python scripts/generate_airline_synthetic.py.
Reproducibility & analysis
- Seed support: pass
--seedto training/evaluation scripts. - CVXPy:
LinearRecoursepreferscvxpyfor exact convex solves; a greedy fallback is implemented whencvxpyis unavailable. - SCMs:
scm.pycontains both hand-coded and learned SCM variants;SCM_Trainercan fit structural equations from data.
Evaluation metrics
- Recourse validity: proportion of previously-negative instances for which an action changes the classifier's decision under the SCM.
- Cost: L1-style or user-defined cost aggregated per instance and summarized by quantiles/means.
- Additional model metrics: MCC thresholding, AUROC, calibration where appropriate.
Notebook → PDF
To export a report-quality PDF (XeLaTeX compatible):
cd HomeWorks/HW3
./scripts/export_notebook_pdf.sh
# Result: output/pdf/hw3_complete_assignment.pdf
Next steps / extensions
- Add domain-specific constraints to the
data_utilsactionability sets. - Replace learned SCMs with richer structural estimators and compare recourse validity.
If you want, I can expand the code/q5_codes/README.md with a CLI reference for every script and example reproduce commands for the provided models/ and results/ artifacts.
- Total size
- 903 MB
- Files
- 2,614
- Last updated
- Sep 12
- Pre-warmed CDN
- US EU US EU