I have 3 classes and my weights are
Class 1: 1
Class 2: 0.333
Class 3: 0.167
How do I input them into the scale_pos_weight parameter?
I know for a binary classification, we input it like below:
model = XGBClassifier(scale_pos_weight=99)
I have 3 classes and my weights are
Class 1: 1
Class 2: 0.333
Class 3: 0.167
How do I input them into the scale_pos_weight parameter?
I know for a binary classification, we input it like below:
model = XGBClassifier(scale_pos_weight=99)
scale_pos_weightarugment is meant for binary classification instead of multi-class classification. You can however use theweightargument to specify a column to use to weigh each observation, see also the answers to this question. – Oxbowerce Oct 26 '21 at 09:30xgboost.DMatrixwith theweightargument, where each observation (not just each class) needs a weight, as seen in the first answer. The second option would be to use theweightargument directly inXGBClassifier, in this case you also have to have a weight for each observation as shown in the second answer. – Oxbowerce Oct 26 '21 at 12:46