I want to solve a regression problem with XGBoost. I'm confused with Learning Task parameter objective [ default=reg:linear ](XGboost), **it seems that 'objective' is used for setting loss function.**But I can't understand 'reg:linear' how to influence loss function. In logistic regression demo(XGBoost logistic regression demo), objective = binary:logistic means loss function is logistic loss function.So 'objective=reg:linear' corresponds to which loss function?
XGBoost Loss for Regression The XGBoost objective function used when predicting numerical values is the “reg:squarederror” loss function. “reg:squarederror”: Loss function for regression predictive modeling problems.
Before running XGBoost, we must set three types of parameters: general parameters, booster parameters and task parameters. Learning task parameters decide on the learning scenario. For example, regression tasks may use different parameters with ranking tasks.
Arguably, there are six (6) hyperparameters for XGBoost that are the most important , which is defined as those with the highest probability of the algorithm yielding the most accurate, unbiased results the quickest without over-fitting: (1) how many sub-trees to train; (2) the maximum tree depth (a regularization ...
So 'objective=reg:linear' corresponds to which loss function?
Squared error
You can take a look at the loss functions ( which are based on the gradient and hessian ) for both logistic regression and linear regression here
https://github.com/dmlc/xgboost/blob/master/src/objective/regression_obj.cc
Note the loss functions are reasonably similar. Just that the SecondOrderGradient
is a constant in square loss
// 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);
}
the authors mention this here https://github.com/dmlc/xgboost/tree/master/demo/regression
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With