Class QuantileL1Loss


  • public class QuantileL1Loss
    extends Loss
    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: ...

    • Constructor Detail

      • QuantileL1Loss

        public QuantileL1Loss​(float quantile)
        Computes QuantileL1Loss for regression problem.
        Parameters:
        quantile - the quantile position of the data to focus on
      • QuantileL1Loss

        public QuantileL1Loss​(java.lang.String name,
                              float quantile)
        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 Detail

      • evaluate

        public NDArray evaluate​(NDList labels,
                                NDList predictions)
        Calculates the evaluation between the labels and the predictions.
        Specified by:
        evaluate in class Evaluator
        Parameters:
        labels - the correct values
        predictions - the predicted values
        Returns:
        the evaluation result