2
$\begingroup$

My question is rather simple what does the parameter scale_pos_weight in xgboost do? I know typically it should be $\frac{sum(negative cases)}{sum(positive cases)}$.
Does it oversample the minority class by that ratio or does it undersample the majority class by inverse of that ratio? Or something else?
Also I would like to know if during cross validation in xgbcv, does the sampling happen on the test part of the cross-validation also or only the train part is affected by scale_pos_weight? Because i've heard that sampling should never be applied to test as it gives over-optimistic results.

$\endgroup$

1 Answer 1

2
$\begingroup$

I guess while computing total error from errors of individual samples, if sample happens to be of a positive class, its error is multiplied by the scale_pos_weight factor. Therefore setting high scale_pos_weight urges optimizer to treat more important (mostly due to its rareness) class with more respect due its higher contribution to the total error value.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.