I am trying to use the XGBClassifier
wrapper provided by sklearn
for a multiclass problem. My classes are [0, 1, 2], the objective that I use is multi:softmax
. When I am trying to fit the classifier I get
xgboost.core.XGBoostError: value 0for Parameter num_class should be greater equal to 1
If I try to set the num_class parameter the I get the error
got an unexpected keyword argument 'num_class'
Sklearn is setting this parameter automatically so I am not supposed to pass that argument. But why do I get the first error?
You need to manually add the parameter num_class
to the xgb_param
# Model is an XGBClassifier
xgb_param = model.get_xgb_params()
xgb_param['num_class'] = 3
cvresult = xgb.cv(xgb_param, ...)
The XGBClassifier does set this value automatically if you use its fit
method, but does not in the cv
method
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With