The ACLED Conflict Alert System (CAST) forecasts organized political violence up to six months into the future. Forecasts are produced at the global, national, and sub-national levels and are disaggregated by event type: battles, explosions/remote violence, and violence against civilians. This public repository hosts the core forecasting workflow, including uncertainty estimation and hierarchical reconciliation built around an LGBM model. See the methodology document for more details.
- Clone the repository to your local machine.
- Create a virtual environment, activate it, and install the required packages using the requirements.txt file.
- Create a
.envfile based on the.env.exampletemplate and add your ACLED API credentials. - Download the necessary raw data files and place them in the
data/raw_datafolder as specified in the Data folder section below. - Update the
config.ymlfile with the correct paths to your raw data files if they differ from the defaults. - Run the
stable_data_prep.pyscript to process the stable data files and save them in thedata/processed_datafolder. - Use the
run_prep.pyscript to prepare the data for the model. - Run the
run_cast.pyscript to execute the CAST model and generate forecasts.
What you need to provide to run this smoothly:
- Raw data files as specified in the Data folder section below.
- Config file (
config.yml) with correct paths to your raw data files if they differ from the defaults. - An ACLED API key and username set in the
.envfile - A
.geojsonfile containing the shapes of the subnational units you wish to forecast. It needs to have columns 'country' and 'admin1'. If it includes the region as well, you may uncomment the relevant section in the feature engineering section of therun_prep.pyscript to include region level features. The best idea is to save it in theraw_datafolder and point to it in the config file. - Optional: a precomputed neighbours file if you want to enable neighbor violence features.
Preparation of the stable data files (i.e. the features not generated from the ACLED data itself). This includes reading in the raw data files, processing them, and writing out the processed data files.
Class contained various preprocessing steps to prepare the data for the model. This mostly includes variable creation and cleaning steps.
Class contains many methods to generate features including lags, counts since, rolling means etc.
Functions used throughout which may require more than should be held in an existing class but are not complex enough to warrant their own class.
Class to run the CAST model. Train, predict, reconcile, compute uncertainty all held in here. It uses the data prepared in run_prep.py and writes out various outputs including cv results, forecasts, and the model.
Script to prepare the data for the model. It uses classes in the preprocess.py and feature_engineer.py and writes a data file ready for the model script to use.
Script to run the CAST model. It uses the cast.py script and writes out various outputs including cv results, forecasts, and the model
In here we keep the raw data files as downloaded from the various sources. As such it can contain at most the following files:
population.tif: raster file containing the population data linkimr.tif: raster file containing the infant mortality rate data linkvdem_24.csv: file containing the VDem data from manual csv download linkelections.csv: file containing the VDem data from manual csv download link
In here we keep the results of the stable_data_prep.py processes. As such it can contain at most the following files:
population.feather: file containing the processed population data from the rasterimr.feather: file containing the processed infant mortality rate data from the rastervdem.feather: file containing the processed VDem data from manual csv downloadelections.feather: file containing the processed VDem data from manual csv downloadneighbours.feather: optional file containing precomputed neighboring admin relationships for the neighbor violence feature