简体   繁体   English

LightGBM时间序列预测如何实现LINEX loss function?

[英]How to implement LINEX loss function for LightGBM time series forecast?

In demand forecasting, it is crucial, to keep in mind, that underestimating demand is hurting most businesses more, because of higher costs as in case of overestimating the demand for a certain product.在需求预测中,请记住,低估需求对大多数企业的伤害更大,因为高估某种产品的需求会增加成本。

The standard loss function for Gradient Boosting machines is the RMSE, which do not have smooth derivates. Gradient Boosting 机器的标准损失 function 是 RMSE,它没有平滑的导数。

To make the objective more "business-like", we could define a custom loss function, that takes the product price into account (for example an asymmetric MSE).为了使目标更“商业化”,我们可以定义一个自定义损失 function,将产品价格考虑在内(例如非对称 MSE)。

Another possibility is the so called LINEX loss function. LINEX stands for linear exponential loss and accounts for asymmetric loss.另一种可能性是所谓的 LINEX 损失 function。LINEX 代表线性指数损失并说明不对称损失。

However, I struggle to implement LINEX in R. I only found a formula without in depth description.然而,我在R中很难实现LINEX。我只找到了一个没有深入描述的公式。 在此处输入图像描述

The illustrated example shows the implementation for an xgboost model.图示示例显示了 xgboost model 的实现。

Does anyone know, how to implement this in parsnip?有谁知道,如何在防风草中实现这个?

Here an example, how you could implement a custom loss function:这是一个示例,如何实现自定义损失 function:

library(tidymodels)
library(lightgbm)
library(bonsai)
mod <- boost_tree("regression") %>% 
  set_engine("lightgbm",
             objective = function(preds, dtrain) {
               truth <- as.numeric(getinfo(dtrain, "label"))
               error <- truth - preds
               gradient <- -2 * error
               hess <- rep.int(2, length(preds))
               list(grad = gradient, hess = hess)
             }
             )

You could have to write a custom yardstick function .您可能必须编写自定义标准 function

You can also add a GitHub issue to get it implemented.您还可以添加一个GitHub 问题来实现它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM