mqloss
(y
:ndarray
, y_hat
:ndarray
, quantiles
:ndarray
, weights
:Optional
[ndarray
]=None
, axis
:Optional
[int
]=None
)
Calculates the Multi-Quantile loss (MQL) between y and y_hat.
MQL calculates the average multi-quantile Loss for
a given set of quantiles, based on the absolute
difference between predicted quantiles and observed values.
$$ \mathrm{MQL}(\mathbf{y}_{\tau},
[\mathbf{\hat{y}}^{(q_{1})}_{\tau}, ... ,\hat{y}^{(q_{n})}_{\tau}]) =
\frac{1}{n} \sum_{q_{i}} \mathrm{QL}(\mathbf{y}_{\tau}, \mathbf{\hat{y}}^{(q_{i})}_{\tau}) $$
The limit behavior of MQL allows to measure the accuracy
of a full predictive distribution $\mathbf{\hat{F}}_{\tau}$ with
the continuous ranked probability score (CRPS). This can be achieved
through a numerical integration technique, that discretizes the quantiles
and treats the CRPS integral with a left Riemann approximation, averaging over
uniformly distanced quantiles.
$$ \mathrm{CRPS}(y_{\tau}, \mathbf{\hat{F}}_{\tau}) =
\int^{1}_{0} \mathrm{QL}(y_{\tau}, \hat{y}^{(q)}_{\tau}) dq $$
Parameters
----------
y: numpy array.
Observed values.
y_hat: numpy array.
Predicted values.
quantiles: numpy array.
Quantiles to compare against.
weights: numpy array, optional.
Weights for weighted average.
axis: None or int, optional.
Axis or axes along which to average a.
The default, axis=None, will average over all of the elements of
the input array. If axis is negative it counts from the last to first.
Returns
-------
mqloss: numpy array or double.
Return the MQL along the specified axis.
References
----------
[1] https://www.jstor.org/stable/2629907