【问题标题】:XGBoost:What is the parameter 'objective' set?XGBoost:“目标”参数设置是什么?
【发布时间】:2017-03-07 00:20:06
【问题描述】:

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

【问题讨论】:

    标签: xgboost


    【解决方案1】:

    那么'objective=reg:linear'对应的是哪个损失函数?

    平方误差

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

    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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-12-22
      • 1970-01-01
      • 2019-09-14
      • 2014-01-15
      • 2019-06-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多