Skip to main content

Stratified Assessments of Forecasts over Earth

Project description

SAFE

Stratified Assessment of Forecasts over Earth

Preprint and Website

Installation

pip install safe-earth

To build from source instead:

# get repo
git clone git@github.com:N-Masi/safe.git

# create dev environment
conda create -n safe.env
conda activate safe.env
pip install --file requirements.txt
conda install --channel conda-forge pygmt plotly typing_extensions

Basic Usage

There are 3 basic steps to any SAFE pipeline:

  1. Measure loss: any function that operates between each predicted $\hat{y}$ and the ground truth $y$. There is a loss calculated for every prediction by a given model at every permutation of gridpoint, timestamp, lead time, variable, and vertical level.

    Example: the latitude-weighted squared difference of $\hat{y}$ and $y$.

  2. Measure stratified error: any function that reduces across gridpoints to calculate a metric for each strata.

    Example: RMSE.

  3. Measure fairness: any function that operates on a set of stratified errors. Calculates a fairness metric for each permutation of model and attribute (e.g., the fairness of GraphCast in prediction by territory).

    Example: greatest absolute difference in RMSEs.

It is most useful to look at the errors and fairness. Errors allow you to see how well a particular model works in a specific strata, which can be useful to decision makers determining which model is most accurate for their country or region. Fairness metrics provide a summary statistic for the overall amount of bias in a model.

For now, loss functions should create dataframes with columns for the output of the function. The name of that column is passed into the error function. Calls to src/safe_earth/metrics/fairness.measure_fairness take in the fairness functions as objects and run them all internally. The first major version of the package will bring this paradigm to the errors as well by taking in loss functions as parameters.

Demos

An example of using SAFE to collect metrics on 6 AIWP models across the territory, subregion, income, and landcover attributes is availabe in demos/iclr_workflow.py. It generates error and fairness data by assessing the models on 2020 ERA5 data. To see the type of analysis that can be performed with this data, you can reproduce the figures and tables from the paper by running demos/iclr_figs.py and demos/iclr_tables.py, respectively.

An interactive notebook utilizing SAFE to investigate territorial disparities is available in demos/interactive_demo.ipynb.

Data Notes

To unify the coordinate system across all integrated data sources, latitude ranges [-90, 90] with index 0 at -90, and longitude [-180, 180) but with index 0 at 0 and a wraparound from 180 to -180 in the middle. This is because metadata sourced from pygeoboundaries_geolab follows this coordinate system, and it is easiest to bring tabular data into conformance.

Testing

Run pytest in the terminal of the repo directory while in a python environment that has pytest installed.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

safe_earth-0.1.5.tar.gz (26.6 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

safe_earth-0.1.5-py2.py3-none-any.whl (26.7 MB view details)

Uploaded Python 2Python 3

File details

Details for the file safe_earth-0.1.5.tar.gz.

File metadata

  • Download URL: safe_earth-0.1.5.tar.gz
  • Upload date:
  • Size: 26.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.10

File hashes

Hashes for safe_earth-0.1.5.tar.gz
Algorithm Hash digest
SHA256 529fce0116379523c6cc43a6e9d8577acea50d8f39566c2506499e4c7d586b9e
MD5 c4fe15bacf5982e32626ef3cf3f9d4d1
BLAKE2b-256 56ec6305dd5c5eacab3daca05f9d3b73956e19bd6477b9ef62185268957d4c1e

See more details on using hashes here.

File details

Details for the file safe_earth-0.1.5-py2.py3-none-any.whl.

File metadata

  • Download URL: safe_earth-0.1.5-py2.py3-none-any.whl
  • Upload date:
  • Size: 26.7 MB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.10

File hashes

Hashes for safe_earth-0.1.5-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 aceb21f18c1746eff497f07b054f0a16d306d54bd44fbb5d5ca44182e754900e
MD5 eade6f8af9a65c2427a4ec2a74f8a36c
BLAKE2b-256 e9a84a46e113fd8333b9264eda0af55b75a72bca72626190051bf25adcaf3ed8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page