Casual Machine Learning for Heterogeneous Treatment Effects: An Empirical Application on Optimal Treatment Assignment
Master Thesis Paper, submitted and presented at CERGE-EI.
This repository contains the code, data, and documentation for my Master Thesis, titled Casual Machine Learning for Heterogeneous Treatment Effects: An Empirical Application on Optimal Treatment Assignment. The thesis explores the utilization of machine learning for improved causal inference. Included are all the necessary scripts and resources to reproduce the results, as well as detailed explanations of the methodologies used. Feel free to explore the materials and reach out if you have any questions or feedback!
Ran on:
- Windows 11
- Python 3.9.13
- tensoflow==2.10.0
- protobuf==3.11.3
- You can install venv to your host Python by running this command in your terminal:
pip install virtualenv
- To use venv in your project, in your terminal, cd to the project folder in your terminal, and run the following command:
git clone git@github.com:klaushajdaraj/ml-treatment-effects.git
cd ml-treatment-effects
python3.9.13 -m venv env
- To activate your virtual environment:
- On Mac:
source env/bin/activate
- On Windows:
env/Scripts/activate.bat //In CMD
env/Scripts/Activate.ps1 //In Powershel
- Install the packages and libraries:
pip install -r requirements.txt
- To deactivate your virtual environment:
~ deactivate
conda create -n ml_treatments_env python=3.9.13
conda activate ml_treatments_env
pip install -r requirements.txt
The file contains the required packages, libraries and dependencies. To install the requirements, run in the terminal:
pip install -r requirements.txt
Contains the CV_Results (see mlmethods) saved from the hundred times performed three-folded cross validation Hitsch Matching for two ML-Methods. Only treatments 1, 2, 4 and 5 were considered.
Contains the CV_Results (see mlmethods) saved from the hundred times performed three-folded cross validation Hitsch Matching for two ML-Methods. All treatments were considered.
Code for creating plots used in the Analytics.ipynb which is the main Jupyter notebook for evaluating the results.
Main script with two ML-Method classes and the code for Hitsch Matching. It is only used for importing on the main script, empty main()
.
Raw data of the experiment from Opitz et al. (2024).
Script for hyper-parameter tuning of the two ML-Methods.
The main Jupyter notebook for creating descriptional statistics, result tables and figures.
Performs the Hitsch Matching with the two ML methods. Adjust the used_treatments
list for the subset of treatments. In addition, there can be found the dictionary with used hyperparameters.
Please note that the paths in the python scripts have to be adjusted to the user's working directory! Therefore, it is necessary to change the paths according to your local directories.
To change the paths, follow the steps:
- Create a file named
config.yaml
in the same working directory. - Inside the config file, set the paths as it follows:
paths:
documents: Paste the path to the directory containing the joblib files for full and sub- treatment set.
data: Paste the path to the directory containing the data file: `expdata.csv`.
params: Paste the path to the directory containing the parameters.
"# machine-learning-treatment-effects" "# ml-treatment-effects"