|
| 1 | +# Causal Inference Benchmarking Framework |
| 2 | +Framework for evaluating causal inference methods. |
| 3 | + |
| 4 | + - [General](#general) |
| 5 | + - [Getting Started](#getting-started) |
| 6 | + - [Prerequisites](#prerequisites) |
| 7 | + - [Installation](#installation) |
| 8 | + - [Usage](#usage) |
| 9 | + - [Citing](#citing) |
| 10 | + - [License](#license) |
| 11 | + - [Authors](#authors) |
| 12 | + |
| 13 | +## General |
| 14 | +Causality-Benchmark is a library developed by IBM Research for benchmarking algorithms that |
| 15 | +estimate causal effect. |
| 16 | +The framework includes unlabeled data, labeled data, and code for scoring algorithm predictions. |
| 17 | +It can benchmark predictions of both population effect size and individual effect size. |
| 18 | + |
| 19 | +The evaluation script is not bounded to the provided data, and can be used on other data as |
| 20 | +long as some basic requirements are kept regarding the formats. |
| 21 | +For more technical details about the evaluation metrics and the data, please refer to the |
| 22 | +framework menuscript **TODO: Link to the menuscript/technical report** |
| 23 | + |
| 24 | +Please note that due to GitHub limitation, only a sample of the data is available in this |
| 25 | +repository. However, you can manually access and download the entire dataset from the |
| 26 | +[Synapse sharing platform](https://www.synapse.org/#!Synapse:syn11294478/files/) |
| 27 | + |
| 28 | +## Getting Started |
| 29 | +### Prerequisites |
| 30 | +Causality-Benchmarking is a Python 3.x library with some backward support for Python 2.7.x. |
| 31 | +The code heavily depends on pandas and requires: |
| 32 | +* pandas >= 0.20.3 |
| 33 | +* numpy >= 1.13.1 |
| 34 | +* future >= 0.16.0 (for Python 2 compatibility) |
| 35 | + |
| 36 | +### Installation |
| 37 | +#### Using git clone |
| 38 | +This will clone the entire repository first, so you would have both the data and the unittests as well, |
| 39 | +on top of the evaluation scripts of the library. This way you could use your tools on the benchmark's |
| 40 | +data also. |
| 41 | +```bash |
| 42 | +git clone https://github.com/IBM-HRL-MLHLS/IBM-Causal-Inference-Benchmarking-Framework.git |
| 43 | +cd IBM-Causal-Inference-Benchmarking-Framework |
| 44 | +python setup.py install |
| 45 | +``` |
| 46 | + |
| 47 | +#### Using pip |
| 48 | +This will only install the evaluation scripts of the library and will include neither the tests |
| 49 | +nor the data. Use this option in case you only want to score using the evaluation metrics. |
| 50 | +```bash |
| 51 | +pip install git+https://github.com/IBM-HRL-MLHLS/IBM-Causal-Inference-Benchmarking-Framework.git |
| 52 | +``` |
| 53 | + |
| 54 | +### Usage |
| 55 | +#### Evaluation |
| 56 | +The evaluation script can be used either from a command line or from inside another Python |
| 57 | +script. |
| 58 | +##### Command-line API |
| 59 | +```bash |
| 60 | +$ cd IBM-Causal-Inference-Benchmarking-Framework/evaluattion |
| 61 | +$ evaluate PATH_TO_PREDICTION_OUTPUT PATH_TO_COUNTERFACTUAL_FILES_DIRECTORY |
| 62 | +``` |
| 63 | +Type `evaluate -h` for the full manual. |
| 64 | + |
| 65 | +##### Python module API |
| 66 | +```python |
| 67 | +from causalbenchmark.evaluate import evaluate |
| 68 | +PATH_TO_PREDICTION_OUTPUT = "/SOME/PATH/TO/YOUR/ESTIMATES" |
| 69 | +PATH_TO_COUNTERFACTUAL_FILES_DIRECTORY = "/SOME/PATH/TO/GROUND/TRUTH/DATA" |
| 70 | +scores = evaluate(PATH_TO_PREDICTION_OUTPUT, PATH_TO_COUNTERFACTUAL_FILES_DIRECTORY) |
| 71 | +``` |
| 72 | + |
| 73 | +##### Population vs individual prediction |
| 74 | +The default behaviour of the scoring script is to evaluate the average treatment effect |
| 75 | +in the population. |
| 76 | +In case the user wish to estimate individual effect size, one should add the `individual` flag: |
| 77 | +```bash |
| 78 | +$ evaluate PATH_TO_PREDICTION_OUTPUT PATH_TO_COUNTERFACTUAL_FILES_DIRECTORY --i |
| 79 | +``` |
| 80 | +```python |
| 81 | +scores = evaluate(PATH_TO_PREDICTION_OUTPUT, PATH_TO_COUNTERFACTUAL_FILES_DIRECTORY, |
| 82 | + individual_prediction=True) |
| 83 | +``` |
| 84 | +##### Expected Files |
| 85 | +* The counterfactual files (holding $y^1$, $y^0$ for each individual), are expected to be a |
| 86 | + directory with different comma-separated-files and their file names corresponding to the |
| 87 | + data-instance but having some suffix (e.g. `"_cf.csv"`). |
| 88 | +* The predictions for population effect size are expected to be one comma-delimited-file with |
| 89 | + every row corresponding to a different data-instance. |
| 90 | +* The prediction for individual effect size are expected to be a directory containing different |
| 91 | + comma-delimited-files, each corresponding to a data-instance and each containing the |
| 92 | + estimated outcome under no-treatment and under positive treatment. |
| 93 | + |
| 94 | +For full explanation, please refer to the menuscript **TODO: link to menuscript** |
| 95 | + |
| 96 | +#### Estimation |
| 97 | +To avoid inflating file sizes for nothing, |
| 98 | +we supply one main covariate file and multiple files containing simulated treatment |
| 99 | +assignment and simulated outcome based on the main covariate matrix. |
| 100 | +An observed dataset, to apply causal inference methods on, can be achieved by compiling |
| 101 | +the covariate matrix and the simulated matrix together. This is done by a simple |
| 102 | +*inner join*. |
| 103 | +A python generator is provided to iterate over all simulated files, combine them with |
| 104 | +the covariate matrix into one complete observed dataset so user can obtain causal estimations |
| 105 | +from. |
| 106 | +```python |
| 107 | +from causalbenchmark.utils import combine_covariates_with_observed |
| 108 | +COVARIATE_FILE_PATH = "/SOME/MAIN/COVARIATE/FILE.csv" |
| 109 | +FACTUAL_FILE_DIR = "/SOME/PATH/TO/DIRECTORY/WITH/FACTUAL/FILES" |
| 110 | +for observed_dataset in combine_covariates_with_observed(COVARIATE_FILE_PATH,FACTUAL_FILE_DIR): |
| 111 | + causal_effect_estimations = apply_my_awesome_model(observed_dataset) |
| 112 | +``` |
| 113 | + |
| 114 | +## Citing |
| 115 | +If you use either the data, the evaluation metrics or the evaluation code, please cite this |
| 116 | +report as follows: |
| 117 | +``` |
| 118 | +@article{causality-benchmark, |
| 119 | + title={......}, |
| 120 | + author={....}, |
| 121 | + journal={arXiv preprint arXiv:xxx.yyyyy}, |
| 122 | + year={2018} |
| 123 | +``` |
| 124 | +**TODO: complete citation info** |
| 125 | + |
| 126 | +## License |
| 127 | +The current content is open source under Apache License 2.0. For full specification see: |
| 128 | +[License.txt](License.txt) |
| 129 | + |
| 130 | +## Authors |
| 131 | +* bullets (link to personal github profile) |
| 132 | +* of |
| 133 | +* authors' (link to personal site) |
| 134 | +* names |
| 135 | + |
| 136 | + |
| 137 | + |
0 commit comments