1
$\begingroup$

I see it is possible to add a weight for unbalanced problems in XGBoost's Scikit-Learn API through scale_pos_weight. Does it have an equivalent in the Learning API? If not,

  • is there a reason behind this?
  • Could this corrective factor/weight also be somehow implemented using the learning API?
| improve this question | | | | |
$\endgroup$
0
$\begingroup$

scikit learn API is just a wrapper that inherits from the base learning one. Since implementing this feature (its just a balance between positive and negative sample weights) is easy developers decided to ommit it in the parent class.

| improve this answer | | | | |
$\endgroup$
0
$\begingroup$

Yes, you can use scale_pos_weight in the native python API; it goes in the params dictionary. E.g.,

params = {'objective': 'binary:logistic',
          'scale_pos_weight': 2.5}
model = xgboost.train(params, dmat)

https://xgboost.readthedocs.io/en/latest/parameter.html#parameters-for-tree-booster https://github.com/dmlc/xgboost/blob/master/demo/kaggle-higgs/speedtest.py

| improve this answer | | | | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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