# Imbalanced dataset with 3 classes xgboost scale_pos_weight parameter

The xgboost classifier states the use of parameter scale_pos_weight for 2-class problems.

I have a highly imbalanced dataset with 3 classes. Classes '1' and '-1' are very rare (~1% of dataset) and class '0' is very common.

How do I set this scale_pos_weight parameter in the xgboost classifier correctly for my classification problem?

• Are you sure that the best way for handling the imbalanced dataset in your case is setting scale_pos_weight parameter? – Alireza Zolanvari Mar 14 '19 at 8:31

For my multiclass classification problem with similar unbalanced data I used the output from sklearn compute_class_weight function:
sklearn.utils.class_weight.compute_class_weight(class_weight, classes, y)