conformal_fair_ite
Generate counterfactual-fair conformal prediction intervals for individual treatment effects, adjusting for demographic parity so coverage stays valid even when protected attributes shift.
Instructions
Counterfactual-fair conformal prediction for ITE (2025). Wraps standard conformal ITE intervals with a demographic-parity adjustment, giving distribution-free coverage under protected-attribute shifts. Validation: validated evidence tier (known-truth, reference, external-parity, or Monte Carlo artifact). Assumptions: Exchangeability for conformal coverage, applied within protected-group strata; Counterfactual fairness: protected attribute excluded from the outcome regression (used only for stratified calibration); ITE ignorability / overlap so the treated and control nuisances are identified. Pre-conditions: DataFrame with y, treat, predictive covariates, and a categorical protected column; Calibration set per protected stratum for group-wise conformal coverage; Optional test_data to emit fair ITE intervals on. Failure modes: A protected stratum has too few calibration rows for valid group-wise quantiles -> Collapse sparse protected categories or pool strata before calibration; protected column accidentally leaks into covariates, breaking counterfactual fairness -> Remove the protected attribute from covariates; pass it only via the protected argument. Alternatives: sp.conformal,...
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| y | Yes | Outcome variable column name or outcome array. | |
| alpha | No | Significance level for confidence intervals and tests. | |
| treat | Yes | Treatment indicator or first-treatment-period column. | |
| detail | No | Payload depth: 'minimal' (~150 tokens) for sub-step calls where only the point estimate is needed; 'standard' (~1K tokens) for diagnostics + coefficient table; 'agent' (~2K tokens, default) adds violations / next_steps / suggested_functions so the LLM can plan its next call without another round-trip. | agent |
| as_handle | No | If true, cache the fitted result on the server and return result_id + result_uri alongside the JSON payload so a subsequent tools/call can chain without re-running. | |
| data_path | Yes | Absolute path or URL to a data file. Supported: .csv / .tsv / .txt (delimited), .parquet / .pq, .feather / .arrow, .xlsx / .xls, .dta (Stata), .json / .jsonl. Schemes: file://, s3://, gs://, https://. | |
| protected | Yes | Protected-attribute column | |
| result_id | No | Optional handle to a previously-fitted result (returned by an earlier call when as_handle=true). Tools that operate on a fitted object accept this in place of re-supplying data_path + columns. | |
| covariates | Yes | Covariate matrix, DataFrame, or column names. | |
| data_columns | No | Optional column projection. Parquet/Feather/Stata loaders honour this for fast partial reads. | |
| data_sample_n | No | Optional uniform random subsample size (seed=0, deterministic) — useful on huge panels. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||