Skip to content

About

Conflict forecasting pipeline for ACLED

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

General Overview:

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.

Set Up Instructions:

  1. Clone the repository to your local machine.
  2. Create a virtual environment, activate it, and install the required packages using the requirements.txt file.
  3. Create a .env file based on the .env.example template and add your ACLED API credentials.
  4. Download the necessary raw data files and place them in the data/raw_data folder as specified in the Data folder section below.
  5. Update the config.yml file with the correct paths to your raw data files if they differ from the defaults.
  6. Run the stable_data_prep.py script to process the stable data files and save them in the data/processed_data folder.
  7. Use the run_prep.py script to prepare the data for the model.
  8. Run the run_cast.py script to execute the CAST model and generate forecasts.

Required Inputs

What you need to provide to run this smoothly:

  1. Raw data files as specified in the Data folder section below.
  2. Config file (config.yml) with correct paths to your raw data files if they differ from the defaults.
  3. An ACLED API key and username set in the .env file
  4. A .geojson file 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 the run_prep.py script to include region level features. The best idea is to save it in the raw_data folder and point to it in the config file.
  5. Optional: a precomputed neighbours file if you want to enable neighbor violence features.

SRC folder:

stable_data_prep.py

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.

preprocess.py

Class contained various preprocessing steps to prepare the data for the model. This mostly includes variable creation and cleaning steps.

feature_engineer.py

Class contains many methods to generate features including lags, counts since, rolling means etc.

utils.py

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.

cast.py

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.

Main Scripts:

run_prep.py

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.

run_cast.py

Script to run the CAST model. It uses the cast.py script and writes out various outputs including cv results, forecasts, and the model

Data folder:

raw_data:

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 link
  • imr.tif: raster file containing the infant mortality rate data link
  • vdem_24.csv: file containing the VDem data from manual csv download link
  • elections.csv: file containing the VDem data from manual csv download link

processed_data:

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 raster
  • imr.feather: file containing the processed infant mortality rate data from the raster
  • vdem.feather: file containing the processed VDem data from manual csv download
  • elections.feather: file containing the processed VDem data from manual csv download
  • neighbours.feather: optional file containing precomputed neighboring admin relationships for the neighbor violence feature

About

Conflict forecasting pipeline for ACLED

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages