我想用 XGBoost 解决回归问题。我对学习任务参数目标 [ default=reg:linear ]( XGboost )感到困惑,**似乎“目标”用于设置损失函数。**但我无法理解“reg:linear”如何影响损失函数。在逻辑回归演示(XGBoost逻辑回归演示)中,objective = binary:logistic表示损失函数是逻辑损失函数。那么'objective=reg:linear'对应哪个损失函数?
那么'objective=reg:linear'对应的是哪个损失函数?
平方误差
您可以在此处查看逻辑回归和线性回归的损失函数(基于梯度和 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);
}
Run Code Online (Sandbox Code Playgroud)
作者在这里提到这个https://github.com/dmlc/xgboost/tree/master/demo/regression
| 归档时间: |
|
| 查看次数: |
8941 次 |
| 最近记录: |