QuantileLoss#
- class pytorch_forecasting.metrics.quantile.QuantileLoss(quantiles: List[float] | None = None, **kwargs)[source]#
Bases:
MultiHorizonMetric
Quantile loss, i.e. a quantile of
q=0.5
will give half of the mean absolute error as it is calculated asDefined as
max(q * (y-y_pred), (1-q) * (y_pred-y))
Quantile loss
- Parameters:
quantiles – quantiles for metric
Methods
loss
(y_pred, target)Calculate loss without reduction.
to_prediction
(y_pred)Convert network prediction into a point prediction.
to_quantiles
(y_pred)Convert network prediction into a quantile prediction.
- loss(y_pred: Tensor, target: Tensor) Tensor [source]#
Calculate loss without reduction. Override in derived classes
- Parameters:
y_pred – network output
y_actual – actual values
- Returns:
loss/metric as a single number for backpropagation
- Return type:
torch.Tensor