QuantileLoss#
- class pytorch_forecasting.metrics.quantile.QuantileLoss(quantiles: list[float] | None = None, **kwargs)[source]#
Bases:
MultiHorizonMetricQuantile loss, i.e. a quantile of
q=0.5will 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