Implementations of the CRPS using PyTorch
Project description
torch-crps
Implementations of the Continuously-Ranked Probability Score (CRPS) using PyTorch
Background
The Continuously-Ranked Probability Score (CRPS) is a strictly proper scoring rule. It assesses how well a distribution with the cumulative distribution function $F$ is explaining an observation $y$
$$ \text{CRPS}(F,y) = \int _{\mathbb {R} }(F(x)-\mathbb {1} (x\geq y))^{2}dx \qquad (\text{integral formulation}) $$
where $1$ denoted the indicator function.
In Section 2 of this paper Zamo & Naveau list 3 different formulations of the CRPS.
Incomplete list of sources that I came across while researching about the CRPS
- Hersbach, "Decomposition of the Continuous Ranked Probability Score for Ensemble Prediction Systems"; 2000
- Gneiting et al.; "Calibrated Probabilistic Forecasting Using Ensemble Model Output Statistis and Minimum CRPS Estimation"; 2004
- Gneiting & Raftery; "Strictly Proper Scoring Rules, Prediction, and Estimation"; 2007
- Zamo & Naveau; "Estimation of the Continuous Ranked Probability Score with Limited Information and Applications to Ensemble Weather Forecasts"; 2018
- Jordan et al.; "Evaluating Probabilistic Forecasts with scoringRules"; 2019
- Olivares & Négiar & Ma et al; "CLOVER: Probabilistic Forecasting with Coherent Learning Objective Reparameterization"; 2023
- Vermorel & Tikhonov; "Continuously-Ranked Probability Score (CRPS)" blog post; 2024
- Nvidia; "PhysicsNeMo Framework" source code; 2025
- Zheng & Sun; "MVG-CRPS: A Robust Loss Function for Multivariate Probabilistic Forecasting"; 2025
Application to Machine Learning
The CRPS can be used as a loss function in machine learning, just like the well-known negative log-likelihood loss which is the log scoring rule.
The parametrized model outputs a distribution $q(x)$. The CRPS loss evaluates how good $q(x)$ is explaining the observation $y$. This is a distribution-to-point evaluation, which fits well for machine learning as the ground truth $y$ almost always comes as fixed values.
For processes over time and/or space, we need to estimate the CRPS for every point in time/space separately.
There is work on multi-variate CRPS estimation, but it is not part of this repo.
Implementation
The integral formulation is infeasible to naively evaluate on a computer due to the infinite integration over $x$.
I found Nvidia's implementation of the CRPS for ensemble preductions in $M log(M)$ time inspiring to read.
:point_right: Please have a look at the documentation to get started.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file torch_crps-0.1.3.tar.gz.
File metadata
- Download URL: torch_crps-0.1.3.tar.gz
- Upload date:
- Size: 22.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
05fefc0b40fb26c1afd7b754e0a0d689dda251430bf173f415148cc6c7d45037
|
|
| MD5 |
8790d30d578cd365433b3ad693a8e403
|
|
| BLAKE2b-256 |
dc54b909b7ea8e5061c11d962b4e1571873e1e985dde1366d9af9575425ecd92
|
Provenance
The following attestation bundles were made for torch_crps-0.1.3.tar.gz:
Publisher:
cd.yaml on famura/torch-crps
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
torch_crps-0.1.3.tar.gz -
Subject digest:
05fefc0b40fb26c1afd7b754e0a0d689dda251430bf173f415148cc6c7d45037 - Sigstore transparency entry: 774460461
- Sigstore integration time:
-
Permalink:
famura/torch-crps@b908c37f2e218901a99a579c7ac6518d8f951b5b -
Branch / Tag:
refs/heads/main - Owner: https://github.com/famura
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cd.yaml@b908c37f2e218901a99a579c7ac6518d8f951b5b -
Trigger Event:
push
-
Statement type:
File details
Details for the file torch_crps-0.1.3-py3-none-any.whl.
File metadata
- Download URL: torch_crps-0.1.3-py3-none-any.whl
- Upload date:
- Size: 8.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
78d03a9852ec2eb0619a82b7c21797966c604cd118fdc462ed9544f838c5ef46
|
|
| MD5 |
38e4ab4cd521cacb1316058833df3f9d
|
|
| BLAKE2b-256 |
f4f1d55e970f6a44e67d538b7945dc560147b52282840ffec6bc1dbfd189bdc3
|
Provenance
The following attestation bundles were made for torch_crps-0.1.3-py3-none-any.whl:
Publisher:
cd.yaml on famura/torch-crps
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
torch_crps-0.1.3-py3-none-any.whl -
Subject digest:
78d03a9852ec2eb0619a82b7c21797966c604cd118fdc462ed9544f838c5ef46 - Sigstore transparency entry: 774460462
- Sigstore integration time:
-
Permalink:
famura/torch-crps@b908c37f2e218901a99a579c7ac6518d8f951b5b -
Branch / Tag:
refs/heads/main - Owner: https://github.com/famura
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cd.yaml@b908c37f2e218901a99a579c7ac6518d8f951b5b -
Trigger Event:
push
-
Statement type: