0
$\begingroup$

I am working on a multi-class classification task for 24 classes using XGBoost. I am training the model as follows:

param = {'max_depth': max_depth, 'eta': learning_rate, 'silent': 1, 'objective': 'multi:softmax', 'num_class': 24}
bst = xgb.train(param, dtrain, num_round)
bst = xgb.Booster({'nthread': 4})
predictions = bst.predict(dval)

I am getting the predictions as this array:

[ 0.5  0.5  0.5 ...,  0.5  0.5  0.5]

I don't know why it's predicting all classes as 0.5 instead of one of the indices in 0 to 23. Do I need to use any other objective parameter?

$\endgroup$
1
  • 2
    $\begingroup$ What is the line bst = xgb.Booster({'nthread': 4}) for? $\endgroup$
    – tagoma
    Nov 26, 2017 at 21:16

1 Answer 1

2
$\begingroup$

I do not know python API, but I guess with the following line you overwrite the trained object with a freshly created booster object (0.5 is a default prediction)

bst = xgb.Booster({'nthread': 4})
$\endgroup$
1
  • $\begingroup$ Worked! I thought this would train using 4 threads. $\endgroup$
    – Hellboy
    Nov 27, 2017 at 14:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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