30

Apart from binary:logistic (which is the default objective function), is there any other built-in objective function that can be used in xbgoost.XGBClassifier ?

Venkatachalam
  • 16,288
  • 9
  • 49
  • 77

3 Answers3

24

That's true that binary:logistic is the default objective for XGBClassifier, but I don't see any reason why you couldn't use other objectives offered by XGBoost package. For example, you can see in sklearn.py source code that multi:softprob is used explicitly in multiclass case.

Moreover, if it's really necessary, you can provide a custom objective function (details here).

Venkatachalam
  • 16,288
  • 9
  • 49
  • 77
kawa
  • 264
  • 2
  • 4
  • what is the binary:logistic, isn't this just the loss function? – Maths12 Jul 02 '20 at 16:25
  • The question was "is there any built-in objective function other than b:l", and this answer says "you can use functions other than b:l". Why on earth was this selected as the right answer? – Helen Jun 20 '22 at 06:35
3

The default objective for XGBClassifier is ['reg:linear] however there are other parameters as well.. binary:logistic-It returns predicted probabilities for predicted class multi:softmax - Returns hard class for multiclass classification multi:softprob - It Returns probabilities for multiclass classification

Note: when using multi:softmax as objective, you need to pass num_class also as num_class is number of parameters defining number of class such as for labelliing (0,1,2), here we have 3 classes, so num_class = 3

0

These are the bulit-in functions available

  • Objective candidate: survival:aft
  • Objective candidate: binary:hinge
  • Objective candidate: multi:softmax
  • Objective candidate: multi:softprob
  • Objective candidate: rank:pairwise
  • Objective candidate: rank:ndcg
  • Objective candidate: rank:map
  • Objective candidate: reg:squarederror
  • Objective candidate: reg:squaredlogerror
  • Objective candidate: reg:logistic
  • Objective candidate: binary:logistic
  • Objective candidate: binary:logitraw
  • Objective candidate: reg:linear
  • Objective candidate: reg:pseudohubererror
  • Objective candidate: count:poisson
  • Objective candidate: survival:cox
  • Objective candidate: reg:gamma
  • Objective candidate: reg:tweedie
  • Objective candidate: reg:absoluteerror
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – AlexK Apr 22 '23 at 21:43