在 LightGBM 中消除 eval、obj (objective) 和 metric 的歧义

Disambiguating eval, obj (objective), and metric in LightGBM

我是在参考 R 库 lightgbm 时提出这个问题,但我认为它同样适用于 Python 和 Multiverso 版本。

有 3 个参数可供您为模型选择感兴趣的统计信息 - metricevalobj。我试图用通俗易懂的语言清楚地区分这三个的不同角色。

文档说:

obj objective function, can be character or custom objective function. Examples include regression, regression_l1, huber, binary, lambdarank, multiclass, multiclass

eval evaluation function, can be (list of) character or custom eval function

metric 没有 R 文档,除了 catch all that says "see paraters.md",它也没有真正解释它,但列出了以下选项:

metric, default={l2 for regression}, {binary_logloss for binary classification},{ndcg for lambdarank}, type=multi-enum, options=l1,l2,ndcg,auc,binary_logloss,binary_error... l1, absolute loss, alias=mean_absolute_error, mae l2, square loss, alias=mean_squared_error, mse l2_root, root square loss, alias=root_mean_squared_error, rmse huber, Huber loss fair, Fair loss poisson, Poisson regression ndcg, NDCG map, MAP auc, AUC binary_logloss, log loss binary_error. For one sample 0 for correct classification, 1 for error classification. multi_logloss, log loss for mulit-class classification multi_error. error rate for mulit-class classification Support multi metrics, separate by , metric_freq, default=1, type=int frequency for metric output is_training_metric, default=false, type=bool set this to true if need to output metric result of training ndcg_at, default=1,2,3,4,5, type=multi-int, alias=ndcg_eval_at,eval_at NDCG evaluation position, separate by ,

我最好的猜测是

  1. obj 是算法的 objective 函数,即它试图最大化或最小化的内容,例如"regression" 表示它正在最小化平方残差
  2. eval 我猜这只是您希望看到的一项或多项附加统计数据,因为您的算法正在拟合。
  3. metric 我不知道这与 objeval
  4. 的用法有何不同

正如你所说,

obj is the objective function of the algorithm, i.e. what it's trying to maximize or minimize, e.g. "regression" means it's minimizing squared residuals.

metric和eval本质上是一样的。它们仅在使用位置上有所不同。 Eval is used with the cross-validation method (because it can be used to evaluate the model for early-stopping etc?). Metric用于普通列车情况

混淆是由于对几个 gbm 变体(xgboost、lightgbm 和 sklearn 的 gbm + 可能是 R 包)的影响而产生的,它们的参数名称都略有不同。例如 python 中的 xgb.cv() 使用 eval 但对于 R 它使用 metric。然后在 lgbm.cv() 中使用 python 和 R eval

我一直很困惑在xgboost和lightgbm之间切换。有一个绝对惊人的resource by Laurae可以帮助您理解每个参数。