Package ai.djl.training.loss
Class QuantileL1Loss
java.lang.Object
ai.djl.training.evaluator.Evaluator
ai.djl.training.loss.Loss
ai.djl.training.loss.QuantileL1Loss
QuantileL1Loss calculates the Weighted Quantile Loss between labels and predictions. It
is useful in regression problems to target the best-fit line at a particular quantile. E.g., to
target the P90, instantiate new QuantileL1Loss("P90", 0.90). Basically, what this loss
function does is to focus on a certain percentile of the data. E.g. q=0.5 is the original default
case of regression, meaning the best-fit line lies in the center. When q=0.9, the best-fit line
will lie above the center. By differentiating the loss function, the optimal solution will yield
the result that, for some special cases like those where \partial forecast / \partial w are
uniform, exactly 0.9 of total data points will lie below the best-fit line.
def quantile_loss(target, forecast, q):
return 2 * np.sum(np.abs((forecast - target) * ((target <= forecast) - q)))
Reference: ...
-
Field Summary
Fields inherited from class ai.djl.training.evaluator.Evaluator
totalInstances -
Constructor Summary
ConstructorsConstructorDescriptionQuantileL1Loss(float quantile) Computes QuantileL1Loss for regression problem.QuantileL1Loss(String name, float quantile) Computes QuantileL1Loss for regression problem. -
Method Summary
Methods inherited from class ai.djl.training.loss.Loss
addAccumulator, elasticNetWeightedDecay, elasticNetWeightedDecay, elasticNetWeightedDecay, elasticNetWeightedDecay, getAccumulator, hingeLoss, hingeLoss, hingeLoss, l1Loss, l1Loss, l1Loss, l1WeightedDecay, l1WeightedDecay, l1WeightedDecay, l2Loss, l2Loss, l2Loss, l2WeightedDecay, l2WeightedDecay, l2WeightedDecay, maskedSoftmaxCrossEntropyLoss, maskedSoftmaxCrossEntropyLoss, maskedSoftmaxCrossEntropyLoss, quantileL1Loss, quantileL1Loss, resetAccumulator, sigmoidBinaryCrossEntropyLoss, sigmoidBinaryCrossEntropyLoss, sigmoidBinaryCrossEntropyLoss, softmaxCrossEntropyLoss, softmaxCrossEntropyLoss, softmaxCrossEntropyLoss, updateAccumulator, updateAccumulatorsMethods inherited from class ai.djl.training.evaluator.Evaluator
checkLabelShapes, checkLabelShapes, getName
-
Constructor Details
-
QuantileL1Loss
public QuantileL1Loss(float quantile) Computes QuantileL1Loss for regression problem.- Parameters:
quantile- the quantile position of the data to focus on
-
QuantileL1Loss
Computes QuantileL1Loss for regression problem.- Parameters:
name- the name of the loss function, default "QuantileL1Loss"quantile- the quantile position of the data to focus on
-
-
Method Details