Counterfactual Tpp
Code and real data for "Counterfactual Temporal Point Processes", NeurIPS 2022
Install / Use
npx skills add Human-Centric-Machine-Learning/counterfactual-tppInstalls into whichever agent you are using.
README
counterfactual-tpp
This is a repository containing code and real data for the paper Counterfactual Temporal Point Processes, published at NeurIPS 2022.
Pre-requisites
This code depends on the following packages:
networkxnumpypandasmatplotlib
to generate map plots:
GeoPandasgeoplot
In order to install the project dependencies you can run the following command:
pip install -r requirements.txt
Code structure
- src/counterfactual_tpp.py: Contains the code to sample rejected events using the superposition property and the algorithm to calculate the counterfactuals.
- src/gumbel.py: Contains the utility functions for the Gumbel-Max SCM.
- src/sampling_utils.py: Contains the code for the Lewis' thinning algorithm (
thinning_Tfunction) and some other sampling utilities. - src/hawkes/hawkes.py: Contains the code for sampling from the hawkes process using the superposition property of tpps. It also includes the algorithm for sampling a counterfactual sequence of events given a sequence of observed events for a Hawkes process.
- src/hawkes/hawkes_example.ipynb: Contains an example of running algorithm 3 (in the paper) for both cases where we have (1) both observed and un-observed events, and (2) the case that we have only the observed events.
- ebola/graph_generation.py: Contains code to build the Ebola network based on the network of connected districts. This code is adopted from the disease-control project.
- ebola/dynamics.py: Contains code for sampling counterfactual sequence of infections given a sequence of observed infections from the SIR porcess (the
calculate_counterfactualfunction). The rest of the code is adopted from the disease-control project, which simulates continuous-time SIR epidemics with exponentially distributed inter-event times.
The directory ebola/data/ebola contains the information about the Ebola network adjanceny matrix and the cleaned ebola outbreak data adopted from the disease-control project.
The directory ebola/map/geojson contains the geographical information of the districts studied in the Ebola outbreak dataset. The geojson files are obtained from Nominatim.
The directory ebola/map/overall_data contains data for generating the geographical maps in the paper, and includs the overall number of infection under applying different interventions.
The directories src/data_hawkes and src/data_inhomogeneous contain observational data used to generate Synthetic plots in the paper. You can use this data to re-generate paper's plots. Otherwise, you can simply generate new random samples by the code.
Experiments
Synthetic
Epidemiological
- Ebola Epidemic Simulation and Counterfactual Calculations
- Generate Geographical Distribution of infections
Citation
If you use parts of the code in this repository for your own research, please consider citing:
@inproceedings{noorbakhsh2022counterfactual,
title={Counterfactual Temporal Point Processes},
author={Noorbakhsh, Kimia and Gomez-Rodriguez, Manuel},
booktitle={Advances in Neural Information Processing Systems},
year={2022}
}
Related Skills
node-connect
385.5kDiagnose OpenClaw Android, iOS, or macOS node pairing, QR/setup code, route, auth, and connection failures.
blender-python-addon
40.5kBlender Python add-on rules for operators, panels, properties, registration, testing, and API-safe scripting
flutter-development-guidelines-cursorrules-prompt-file
40.5kCursor rules for Flutter development with MVVM architecture, Riverpod state management, Material widgets, and Dart style guidelines.
commit-push-pr
140.7kCommit, push, and open a PR
Languages
Security Score
Audited on Mar 17, 2026
