Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XGBoost:What is the parameter 'objective' set?

Tags:

xgboost

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?

like image 438
Peng He Avatar asked Oct 25 '16 05:10

Peng He


People also ask

What is the objective in XGBoost?

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.

What are the parameters in XGBoost?

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.

What are the most important parameters in XGBoost?

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 ...


1 Answers

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

like image 65
T. Scharf Avatar answered Sep 28 '22 19:09

T. Scharf