KZ's Brain Dump

CRPS

The main theme of machine learning is that we (even implicitly) assume some underlying distribution of the data. When someone grabs a L2 loss (MSE) or L1 loss (MAE), they are implicitly assuming a Gaussian or Laplace distribution for their underlying model. In this sense, I mean that we have a model parameterized by $\theta$ such that $X \sim p_\theta(X)$, where $p_\theta$ defines the underlying distribution. One unique loss that I’ve seen that actually works quite well is the CRPS loss.

CRPS stands for Continuously ranked probability score. Some people refer to it as a form of “energy score”. The official definition is associated with a CDF $F$:

$$CRPS(F, y) = \int_{-\infty}^{\infty} (F(x) - \mathbb{1}(y \geq x))^2 dx$$

To derive the discrete version, we note that:

$$\int_{-\infty}^{\infty} (\mathbb{1}(x \geq a) - \mathbb{1}(x \geq b))^2 dx = |a-b|$$

Another identity that we need is that:

$$2(a-b)(c-b) = (a-b)^2 - (a-c)^2 + (b-c)^2$$

What this means is that: \begin{align*} CRPS(F, y) &= \int_{-\infty}^\infty (E[\mathbb{1}(X \geq x)] - \mathbb{1}(y \geq x))^2 dx \\ &= \int_{-\infty}^\infty (E[\mathbb{1}(X \geq x)] - \mathbb{1}(y \geq x))(E[\mathbb{1}(X’ \geq x)] - \mathbb{1}(y \geq x)) dx \\ &= E_{X, X’} \int_{-\infty}^\infty (\mathbb{1}(X \geq x) - \mathbb{1}(y \geq x))(\mathbb{1}(X’ \geq x) - \mathbb{1}(y \geq x)) dx \\ &= E_{X, X’} \frac{1}{2} |X - y| + \frac{1}{2} |X’ - y| - |X - X’| \\ &= E|X - y| - E|X - X’| \end{align*}

The finite term estimator (unbiased) will then be given by:

$$\frac{1}{n}\sum_{i=1}^n |X_i - y| - \frac{1}{2n(n-1)}\sum_{i=1}^n\sum_{j=1}^n |X_i - X_j|$$

With this, we can train “ensembles” instead of individual models. The advantage of this metric is that it is “proper” in that CRPS is uniquely minimized when the forecast CDF is the true CDF.

Comments