Essentially I have the same problem as this person. https://discuss.analyticsvidhya.com/t/how-to-resolve-multi-class-prediction-error-in-xgboost-in-r/7030
table(target)
0 1 2
22824 4317 32259
table(pred)
0 1
13559 1291
As you can see XGBoost doesn’t output three classes.
Here is my code.
best_params <- list(‘max.depth’ = 2,
‘eta’ = 0.010,
‘gamma’ = 1,
‘colsample_bytree’ = 0.5,
‘min_child_weight’ = 2,
‘objective’ = “multi:softmax”,
‘num_class’ = 3,
‘eval_metric’ = ‘merror’
)
model <- xgboost(train1, target, params=best_params, nrounds=100)
pred <- predict(model, test1)
Any idea where I am going wrong here?