{"id":28532352,"url":"https://github.com/predict-idlab/dose-response-conformal-prediction","last_synced_at":"2026-02-14T05:31:19.101Z","repository":{"id":278214430,"uuid":"859224152","full_name":"predict-idlab/dose-response-conformal-prediction","owner":"predict-idlab","description":null,"archived":false,"fork":false,"pushed_at":"2025-02-18T15:38:42.000Z","size":14897,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-06-09T15:53:05.259Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/predict-idlab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-18T09:50:32.000Z","updated_at":"2025-02-18T15:38:46.000Z","dependencies_parsed_at":"2025-02-18T16:38:01.791Z","dependency_job_id":null,"html_url":"https://github.com/predict-idlab/dose-response-conformal-prediction","commit_stats":null,"previous_names":["predict-idlab/dose-response-conformal-prediction"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/predict-idlab/dose-response-conformal-prediction","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/predict-idlab%2Fdose-response-conformal-prediction","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/predict-idlab%2Fdose-response-conformal-prediction/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/predict-idlab%2Fdose-response-conformal-prediction/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/predict-idlab%2Fdose-response-conformal-prediction/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/predict-idlab","download_url":"https://codeload.github.com/predict-idlab/dose-response-conformal-prediction/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/predict-idlab%2Fdose-response-conformal-prediction/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264091961,"owners_count":23556216,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-09T15:38:14.394Z","updated_at":"2026-02-14T05:31:19.096Z","avatar_url":"https://github.com/predict-idlab.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Conformal Prediction for Dose-Response Models\n\n\u003e This library provides a conformal prediction framework for dose-response models and for uncertainty quantification in counterfactual explanation of continuous features\n\n## Installation ⚙️\n\n_WORK IN PROGRESS_\n\n## Usage 🛠\n\nThe conformal prediction for dose-response models builds upon the Crepes and weighted crepes framework.\n\n```py\nfrom WCDRF.base import *\n\nX, T, y = ...  # your continuous treatment dataset\n\nX_train, X_cal = ... # your calibration and train split for covariates X\nT_train, T_cal = ... # your calibration and train split for treatment T\ny_train, y_cal = ... # your calibration and train split for outcome y\n\nX_target = ... # your target sample or target dataset\n\n# You can specify any regression model for either propensity or outcome model\npropensity_model = ...\noutcome_model = ... \n\n# Specify the DRFWrapRegressor which is an extension of the Wrap Regressor from Weighted Crepes for Dose-Response Functions (DRF)\ndose_response_wrapper = DRFWrapRegressor(propensity_model, outcome_model)\ndose_response_wrapper.fit([X_train, T_train], y_train)\n\n# Calibrate and fit the propensity estimator which uses Conformal Predictive Systems under the hood\ndose_response_wrapper.fit_propensity(X_train, T_train)\ndose_response_wrapper.calibrate_propensity(X_cal, T_cal)\n\n# If you are planning to perform many calibrations on the same calibration set, it is computationally better to perform a prepare_calibration, it uses a multiplier of 0.2 by default\ndose_response_wrapper.prepare_calibration(X_cal, T_cal)\n\n# Define a treatment vector t0_vector with length equal to X_train.\ntarget_dataset = ... # concat X_target with t0_vector\n\n# The options for calibrate are: CPS (default=False, to use conformal predictive systems), use_propensity (default=True, to use the propensity weights), and local_conditional_mode (default=True, to use the local mode)\ndose_response_wrapper.calibrate(target_dataset, y_cal, T_cal, target_treatment = t0)\n\n# If you want the prediction intervals for multiple coverages, e.g. 50%, 80%, 90%, and 95% use:\nprediction_intervals_matrix = dose_response_wrapper.predict_multi_int(\n                                X = target_dataset,\n                                y_min = np.min(y_train) - np.abs(np.min(y_train)),\n                                y_max = np.max(y_train) + np.abs(np.max(y_train)),\n                                confidence_range = [0.5, 0.8, 0.9, 0.95]\n                                )\n# prediction_intervals_matrix has dimensions: [coverage_idx, target_dataset_idx, 2], with [coverage_idx, target_dataset_idx, 0] being the lower bound and [coverage_idx, target_dataset_idx, 1] the upper bound\n\n# Otherwise simply use\nprediction_intervals = dose_response_wrapper.predict_int(\n                                X = target_dataset,\n                                y_min = np.min(y_train) - np.abs(np.min(y_train)),\n                                y_max = np.max(y_train) + np.abs(np.max(y_train)),\n                                confidence = 0.9\n                                )\n# prediction_intervals has dimensions: [target_dataset_idx, 2], with [target_dataset_idx, 0] being the lower bound and [target_dataset_idx, 1] the upper bound\n```\nthe [WCDRF_experiments](https://github.com/predict-idlab/conformal_prediction_dose_response/blob/main/WCDRF_experiments.ipynb) notebook contains the experiments of the paper and shows how to apply the method. \n\nAdditionally, to generate synthetic data from any of the three setups and scenarios the following code can be utilized, using code from synthetic_data_generation.py:\n\n```py\nfrom WCDRF.synthetic_data_generation import *\n\nEXPERIMENT_SOURCE = 2\nEXPERIMENT_SCENARIO = 1\n\nsynthetic_generator = synthetic_data_generator(source = EXPERIMENT_SOURCE, scenario = EXPERIMENT_SCENARIO)\nsynthetic_DRF_df = synthetic_generator.generate_synthetic_DRF_data(N = 5000)\n\n# If you would need the true propensity distribution\nOraclePropensityWrapperObject = OraclePropensityWrapper(synthetic_generator)\n\nfeatures = list(synthetic_DRF_df.columns.values[:-2])\ntreatment = \"W\"\noutcome = \"Y\"\n```\nThe [AMICAS](https://github.com/predict-idlab/dose-response-conformal-prediction/blob/main/AMICAS/AMICAS_usecase.ipynb) notebook contains the experiments of the semi-synthetic paper. The AMICAS simulator can be ran by running the MAIN_PROGRAM_AMICAS.m file to generate the BIS.csv file. To generate the counterfactual results for the BIS you need to run Counter_factualMAIN_PROGRAM_AMICAS.m using a parallelized Matlab.\n\n## Features ✨\n\n* Continuous treatment uncertainty quantification\n* Modifiable weights\n* Model-agnostic\n* Synthetic data generators\n \n## Referencing our package :memo:\n\nIf you use this code in a scientific work, we would highly appreciate citing us as:\n\n```bibtex\n@misc{verhaeghe2024conformalpredictiondoseresponsemodels,\n      title={Conformal Prediction for Dose-Response Models with Continuous Treatments}, \n      author={Jarne Verhaeghe and Jef Jonkers and Sofie Van Hoecke},\n      year={2024},\n      eprint={2409.20412},\n      archivePrefix={arXiv},\n      primaryClass={cs.LG},\n      url={https://arxiv.org/abs/2409.20412}, \n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpredict-idlab%2Fdose-response-conformal-prediction","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpredict-idlab%2Fdose-response-conformal-prediction","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpredict-idlab%2Fdose-response-conformal-prediction/lists"}