XGBoost:参数 'objective'设置的是什么?

标签 xgboost

我想用 XGBoost 解决回归问题。我对学习任务参数目标 [ default=reg:linear ]( XGboost ) 感到困惑,**似乎“目标”用于设置损失函数。**但我无法理解“reg:linear”如何影响损失函数。在逻辑回归演示( XGBoost logistic regression demo )中,objective = binary:logistic 表示损失函数是逻辑损失函数。那么 'objective=reg:linear' 对应哪个损失函数?

最佳答案

So 'objective=reg:linear' corresponds to which loss function?



平方误差

您可以在此处查看逻辑回归和线性回归的损失函数(基于梯度和 hessian)

https://github.com/dmlc/xgboost/blob/master/src/objective/regression_obj.cc

请注意,损失函数相当相似。只是SecondOrderGradient是平方损失的常数
// common regressions
// linear regression
struct LinearSquareLoss {
  static float PredTransform(float x) { return x; }
  static bool CheckLabel(float x) { return true; }
  static float FirstOrderGradient(float predt, float label) { return predt - label; }
  static float SecondOrderGradient(float predt, float label) { return 1.0f; }
  static float ProbToMargin(float base_score) { return base_score; }
  static const char* LabelErrorMsg() { return ""; }
  static const char* DefaultEvalMetric() { return "rmse"; }
};
// logistic loss for probability regression task
struct LogisticRegression {
  static float PredTransform(float x) { return common::Sigmoid(x); }
  static bool CheckLabel(float x) { return x >= 0.0f && x <= 1.0f; }
  static float FirstOrderGradient(float predt, float label) { return predt - label; }
  static float SecondOrderGradient(float predt, float label) {
    const float eps = 1e-16f;
    return std::max(predt * (1.0f - predt), eps);
  } 

作者在这里提到了这一点 https://github.com/dmlc/xgboost/tree/master/demo/regression

关于XGBoost:参数 'objective'设置的是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40231686/

相关文章:

r - Lime:glmnet(x[, c(features, j) 中的错误,x 应该是具有 2 列或更多列的矩阵

python - XGBoost (Python) 生存模型预测

python - GridSearchCV 在管道中将 fit_params 传递给 XGBRegressor 产生 "ValueError: need more than 1 value to unpack"

python - XGBoost 和稀疏矩阵

python - XGBoost 和 scikit 优化 : BayesSearchCV and XGBRegressor are incompatible - why?

python - BayesSearchCV 跳过 : ValueError: Not all points are within the bounds of the space

python - 使用 XGBoost 根据输入预测重要性或百分比

Python 用 0-x 索引替换列值(对于 xgboost)

python - 减少 Python 中 xgboost 增量训练的错误率

r - xgboost R包安装失败