I am working with a very large dataset that would benefit from using training continuation with the xgb_model
parameter in xgb.train()
. The label (Y) of dataset itself has 4 classes and is highly imbalanced, so I would like to generate per-label PR curves for it to evaluate its performance, and would thus need to treat each class as it's own binary problem using a one-vs-rest classifier. After a lot of reading I haven't found an equivalent to sklearn's OneVsRestClassifier
in the xgboost library. Could anyone provide some guidance on how to implement continuously training one-vs-rest classifiers using the XGBoost library? Thank you in in advance.
1 Answer
Try to give sklearn wrapper of xgboost to sklearn OneVsRestClassifier.
https://xgboost.readthedocs.io/en/latest/python/python_api.html#module-xgboost.sklearn
If it doesn't work you can create four different label arrays in which samples belong to corresponding class labeled as 1s, and others as 0. Then training with each of the label arrays you can get results for each class.
-
$\begingroup$ Thanks, but as I mentioned I specifically need to use the low-level xgboost library (not sklearn) so I can take advantage of training continuation. $\endgroup$ Apr 20, 2021 at 18:54
OneVsRestClassifier
. My guess is you'd just need to do this manually, looping over target classes. $\endgroup$