CoPro

CoPro: a data-driven modelling framework for conflict risk projections - Published in JOSS (2021)

https://github.com/jannishoch/copro

Science Score: 98.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 3 DOI reference(s) in README and JOSS metadata
  • Academic publication links
    Links to: joss.theoj.org, zenodo.org
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
    Published in Journal of Open Source Software

Keywords

climate conflict environment projection risk security

Keywords from Contributors

mesh

Scientific Fields

Artificial Intelligence and Machine Learning Computer Science - 69% confidence
Medicine Life Sciences - 40% confidence
Last synced: 4 months ago · JSON representation ·

Repository

(ML) model for computing conflict risk from climate, environmental, and societal drivers.

Basic Info
Statistics
  • Stars: 9
  • Watchers: 2
  • Forks: 0
  • Open Issues: 7
  • Releases: 16
Topics
climate conflict environment projection risk security
Created almost 6 years ago · Last pushed 8 months ago
Metadata Files
Readme Contributing License Code of conduct Citation

README.rst

===============
CoPro
===============

Welcome to CoPro, a machine-learning tool for conflict risk projections based on climate, environmental, and societal drivers.

.. image:: https://img.shields.io/badge/License-MIT-blue.svg
    :target: https://github.com/JannisHoch/copro/blob/dev/LICENSE

.. image:: https://readthedocs.org/projects/copro/badge/?version=latest
    :target: https://copro.readthedocs.io/en/latest/?badge=latest

.. image:: https://img.shields.io/github/v/release/JannisHoch/copro
    :target: https://github.com/JannisHoch/copro/releases/tag/v2.0.1

.. image:: https://zenodo.org/badge/254407279.svg
    :target: https://doi.org/10.5281/zenodo.4061705

.. image:: https://badges.frapsoft.com/os/v2/open-source.svg?v=103
    :target: https://github.com/ellerbrock/open-source-badges/

.. image:: https://joss.theoj.org/papers/1f03334e56413ff71f65092ecc609aa4/status.svg
    :target: https://joss.theoj.org/papers/1f03334e56413ff71f65092ecc609aa4

.. .. image:: https://mybinder.org/badge_logo.svg
..     :target: https://mybinder.org/v2/gh/JannisHoch/copro/dev?filepath=%2Fexample%2Fnb_binder.ipynb

Model purpose
--------------

As primary model output, CoPro provides maps of conflict risk.

To that end, it employs observed conflicts as target data together with (user-provided) socio-economic and environmental sample data to train different classifiers (RFClassifier, kNearestClassifier, and Support Vector Classifier).
While the samples have the units of the data, the target value is converted to Boolean, where a 0 indicates no conflict occurrence and 1 indicates occurrence.
To capture the geographical variability of conflict and socio-environmental drivers, the model is spatially explicit and calculates conflict risk at a (user-specified) aggregation level.
This way, the model can also capture the relevant sub-national variability of conflict and conflict drivers.
Model robustness is determined using a split-sample test where a part of the data is used to train the model, while the other part is used to evaluate the outcome. 
Throughout this process, the geographical unit is tracked to be able to map the resulting conflict risk to the correct areas.

In addition to the calculation of conflict risk, can the model, for instance, be used to make scenario projections, evaluate the relative feature importances, or benchmark different datasets.

All in all, CoPro supports the mapping of current and future areas at risk of conflict, while also facilitating obtaining a better understanding of the underlying processes.

Installation
----------------

To install copro, first clone the code from GitHub. It is advised to create an individual python environment first. 
You can then install the model package into this environment.

To do so, you need to have Anaconda or Miniconda installed. For installation guidelines, see `here `_.

.. code-block:: console

    $ git clone https://github.com/JannisHoch/copro.git
    $ cd path/to/copro
    $ conda env create -f environment.yml
    $ conda activate copro

To install CoPro in editable mode in this environment, run this command next in the CoPro-folder:

.. code-block:: console

    $ pip install -e .

When using Jupyter Notebook, it can be handy to have the copro environment available. It can be installed into Jupyter Notebook with the following command:

.. code-block:: console

    $ python -m ipykernel install --name=copro

Command-line script
--------------------

To be able to run the model, the conda environment has to be activated first.

.. code-block:: console

    $ conda activate copro

To run the model from command line, a command line script is provided. The usage of the script is as follows:

.. code-block:: console

    Usage: copro_runner [OPTIONS] CFG

    Main command line script to execute the model. 
    All settings are read from cfg-file.
    One cfg-file is required argument to train, test, and evaluate the model.
    Multiple classifiers are trained based on different train-test data combinations.
    Additional cfg-files for multiple projections can be provided as optional arguments, whereby each file corresponds to one projection to be made.
    Per projection, each classifiers is used to create separate projection outcomes per time step (year).
    All outcomes are combined after each time step to obtain the common projection outcome.

    Args:     CFG (str): (relative) path to cfg-file

    Options:
    -plt, --make_plots        add additional output plots
    -v, --verbose             command line switch to turn on verbose mode

This help information can be also accessed with

.. code-block:: console

    $ copro_runner --help

All data and settings are retrieved from the settings-file (cfg-file) which needs to be provided as inline argument.

In case issues occur, updating ``setuptools`` may be required.

.. code-block:: console

    $ pip3 install --upgrade pip setuptools

Example data
----------------

Example data for demonstration purposes can be downloaded from `Zenodo `_.
To facilitate this process, the bash-script ``download_example_data.sh`` can be called in the example folder under `/_scripts`.

With this (or other) data, the provided configuration-files (cfg-files) can be used to perform a reference run or a projection run. 
All output is stored in the output directory specified in the cfg-files. 
In the output directory, two folders are created: one name `_REF` for output from the reference run, and `_PROJ` for output for projections.

.. important::

    The example data works with copro version < 2.0.0. 
    For the latest version, the data needs to be realigned with the new config-file requirements.

Jupyter notebooks
^^^^^^^^^^^^^^^^^^

There are multiple jupyter notebooks available to guide you through the model application process step-by-step.

It is possible to execute the notebooks cell-by-cell and explore the full range of possibilities.
Note that in this case the notebooks need to be run in the right order as some temporary files will be saved to file in one notebook and loaded in another!
This is due to the re-initalization of the model at the beginning of each notebook and resulting deletion of all files in existing output folders.

The notebooks are also used to exemplify the `Workflow `_ of CoPro.

Command-line
^^^^^^^^^^^^^^^^^^

While the notebooks are great for exploring, the command line script is the envisaged way to use CoPro.

To only test the model for the reference situation and one projection, the cfg-file for the reference run is the required argument.
This cfg-file needs to point to the cfg-file of the projection in turn.

.. code-block:: console

    $ cd path/to/copro/example
    $ copro_runner example_settings.cfg

Alternatively, the same commands can be executed using a bash-file.

.. code-block:: console

    $ cd path/to/copro/example/_scripts
    $ sh run_command_line_script.sh

Validation
^^^^^^^^^^^^^^^^^^

The reference model makes use of the `UCDP Georeferenced Event Dataset `_ for observed conflict. 
The selected classifier is trained and validated against this data.

Main validation metrics are the ROC-AUC score as well as accuracy, precision, and recall. 
All metrics are reported and written to file per model evaluation.

With the example data downloadable from `Zenodo `_, a ROC-AUC score of above 0.8 can be obtained. 
Note that with additional and more explanatory sample data, the score will most likely increase.

.. figure:: docs/_static/roc_curve.png

Additional ways to validate the model are showcased in the `Workflow `_.

Documentation
---------------

Extensive model documentation including full model API description can be found at http://copro.rtfd.io/

Code of conduct and Contributing
---------------------------------

The project welcomes contributions from everyone! 
To make collaborations as pleasant as possible, we expect contributors to the project to abide by the Code of Conduct.

License
--------

CoPro is released under the MIT license.

Authors
----------------

* Jannis M. Hoch (Utrecht University, now Fathom)
* Sophie de Bruin (Utrecht University & PBL)
* Niko Wanders (Utrecht University)

Owner

  • Name: Jannis Hoch
  • Login: JannisHoch
  • Kind: user
  • Location: the Netherlands

JOSS Publication

CoPro: a data-driven modelling framework for conflict risk projections
Published
February 21, 2021
Volume 6, Issue 58, Page 2855
Authors
Jannis M. Hoch ORCID
Department of Physical Geography, Utrecht University, Utrecht, the Netherlands
Sophie de Bruin ORCID
Department of Physical Geography, Utrecht University, Utrecht, the Netherlands, PBL Netherlands Environmental Assessment Agency, the Hague, the Netherlands
Niko Wanders ORCID
Department of Physical Geography, Utrecht University, Utrecht, the Netherlands
Editor
Sebastian Benthall ORCID
Tags
climate change projections conflict climate security water risk

Citation (CITATION.cff)

cff-version: "1.1.0"
message: "If you use this software, please cite it using these metadata."
title: CoPro
version: "v2.0.2"
authors: 
  - family-names: "Hoch"
    given-names: "Jannis"
    orcid: "https://orcid.org/0000-0003-3570-6436"
    affiliation: "Fathom"
  - family-names: "de Bruin"
    given-names: "Sophie"
    orcid: "https://orcid.org/0000-0003-3429-349X"
    affiliation: "PBL Netherlands Environmental Assessment Agency"
  - family-names: "Wanders"
    given-names: "Niko"
    orcid: "https://orcid.org/0000-0002-7102-5454"
    affiliation: "Utrecht University"
date-released: 2024-12-20
doi: "10.5281/zenodo.4061705"
license: MIT
repository-code: "https://github.com/JannisHoch/copro"
keywords: 
  - conflict
  - "machine learning"
  - "climate change"
  - water
  - scenarios
  - projections
  - "climate security"

GitHub Events

Total
  • Release event: 2
  • Watch event: 3
  • Delete event: 16
  • Push event: 19
  • Pull request event: 24
  • Create event: 17
Last Year
  • Release event: 2
  • Watch event: 3
  • Delete event: 16
  • Push event: 19
  • Pull request event: 24
  • Create event: 17

Committers

Last synced: 5 months ago

All Time
  • Total Commits: 621
  • Total Committers: 3
  • Avg Commits per committer: 207.0
  • Development Distribution Score (DDS): 0.01
Past Year
  • Commits: 9
  • Committers: 2
  • Avg Commits per committer: 4.5
  • Development Distribution Score (DDS): 0.444
Top Committers
Name Email Commits
Jannis j****h@u****l 615
dependabot[bot] 4****] 5
Jannis Hoch j****h@i****g 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 4 months ago

All Time
  • Total issues: 40
  • Total pull requests: 100
  • Average time to close issues: 4 months
  • Average time to close pull requests: 7 days
  • Total issue authors: 3
  • Total pull request authors: 3
  • Average comments per issue: 1.73
  • Average comments per pull request: 0.05
  • Merged pull requests: 93
  • Bot issues: 0
  • Bot pull requests: 32
Past Year
  • Issues: 0
  • Pull requests: 17
  • Average time to close issues: N/A
  • Average time to close pull requests: about 3 hours
  • Issue authors: 0
  • Pull request authors: 2
  • Average comments per issue: 0
  • Average comments per pull request: 0.0
  • Merged pull requests: 17
  • Bot issues: 0
  • Bot pull requests: 10
Top Authors
Issue Authors
  • JannisHoch (30)
  • Sophiepieternel1 (7)
  • soodoku (3)
Pull Request Authors
  • JannisHoch (71)
  • dependabot[bot] (40)
  • Sophiepieternel1 (10)
Top Labels
Issue Labels
wishlist (5) enhancement (5) v1.0-beta (4) documentation (3) bug (2) wontfix (2) help wanted (1) v2 (1)
Pull Request Labels
dependencies (40) python (4)

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 14 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 4
  • Total maintainers: 1
pypi.org: copro

Python-model build on scikit-learn functions, designed to facilitate the set-up, execution, and evaluation of machine-learning models for the study of the climate-conflict nexus.

  • Versions: 4
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 14 Last month
Rankings
Dependent packages count: 10.1%
Average: 39.5%
Downloads: 41.1%
Dependent repos count: 67.2%
Maintainers (1)
Last synced: 4 months ago

Dependencies

docs/requirements.rtd.txt pypi
  • ConfigParser ==5.0.0
  • Sphinx >=3.0.3
  • bump2version ==0.5.11
  • click ==7.1.1
  • coverage ==4.5.4
  • descartes ==1.1.0
  • flake8 ==3.7.8
  • geopandas ==0.7.0
  • ipython ==7.16.3
  • jinja2 ==2.11.3
  • matplotlib ==3.2.1
  • nbconvert ==6.3.0
  • nbsphinx ==0.8.5
  • nbsphinx_link ==1.3.0
  • netCDF4 ==1.5.3
  • notebook >=6.1.5
  • numpy ==1.22.0
  • pandas ==1.0.3
  • pip >=19.2.3
  • pytest ==4.6.5
  • pytest-runner ==5.1
  • rasterio ==1.1.3
  • rasterstats ==0.14.0
  • rioxarray ==0.0.26
  • scikit-learn ==0.22.1
  • seaborn ==0.10.1
  • setuptools ==49.6
  • tox ==3.14.0
  • twine ==1.14.0
  • watchdog ==0.9.0
  • wheel ==0.33.6
  • xarray ==0.15.0
requirements_dev.txt pypi
  • click ==7.1.2 development
  • configparser ==5.0.0 development
  • coverage ==4.5.4 development
  • descartes ==1.1.0 development
  • flake8 ==3.7.8 development
  • geopandas ==0.8.0 development
  • ipython ==7.16.3 development
  • matplotlib ==3.2.1 development
  • nbconvert ==6.3.0 development
  • netcdf4 ==1.5.3 development
  • notebook >=6.1.5 development
  • numpy ==1.22.0 development
  • pandas ==1.0.3 development
  • pip ==21.1 development
  • pyproj ==2.6.0 development
  • pytest ==5.4.2 development
  • pytest-runner ==5.2 development
  • rasterio ==1.1.0 development
  • rasterstats ==0.14 development
  • rioxarray ==0.0.26 development
  • scikit-learn ==0.22.1 development
  • seaborn ==0.10.1 development
  • setuptools ==49.6 development
  • sphinx ==3.0.3 development
  • tox ==3.14.0 development
  • xarray ==0.15.1 development
.github/workflows/python-publish.yml actions
  • actions/checkout v2 composite
  • actions/setup-python v2 composite
  • pypa/gh-action-pypi-publish 27b31702a0e7fc50959f5ad993c78deac1bdfc29 composite
environment.yml pypi
setup.py pypi