MQLoss
(y
:Tensor
, y_hat
:Tensor
, quantiles
:Tensor
, mask
:Tensor
=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: tensor (batch_size, output_size).
Actual values in torch tensor.
y_hat: tensor (batch_size, output_size).
Predicted values in torch tensor.
mask: tensor (batch_size, output_size).
Specifies date stamps per serie to consider in loss.
quantiles: tensor(n_quantiles).
Quantiles to estimate from the distribution of y.
Returns
-------
mqloss: tensor(n_quantiles).
Average multi-quantile loss.
References
----------
[1] https://www.jstor.org/stable/2629907