5
votes

Here is my code:

xgb <- xgboost(data = as.matrix(df_all_combined), 
               label = as.matrix(target_train), 
               eta = 0.1,
               max_depth = 15, 
               nround=100, 
               subsample = 0.5,
               colsample_bytree = 0.5,
               seed = 1,
               eval_metric = "auc",
               objective = "binary:logistic",
               num_class = 12,
               nthread = 3)

Getting the below Error:

Error in xgb.iter.update(bst$handle, dtrain, iteration - 1, obj) : [09:17:34] amalgamation/../src/objective/regression_obj.cc:90: Check failed: (preds.size()) == (info.labels.size()) labels are not correctly providedpreds.size=840756, label.size=70063

Could anyone help me out to solve this issue? Not able to figure out the issue.

4
Ask a question with more discription. It will help for others to answer.hennamusick
looks like its saying something about the size of labels not matching data dimensions. Example data that reproduces the error makes helping much more feasible.zacdav
It would help if you provide a small sample of data. Change the names of any sensitive field if necessary.cousin_pete

4 Answers

5
votes

Try remove num_class = 12 from your parameters.

1
votes

The error says: labels are not correctly provided preds.size=840756, label.size=70063

This means that number of rows in df_all_combined does not correspond to the number of rows in target_train

So target_train should be of the shape (840756,)

0
votes

Xgboost has a bug with multiclass classification. It uses preds.size () = info.labels.size() * num_classes, while using 'auc' which is wrong. So use any other metric like merror.

0
votes

The Objective and num_class donot seem to be in sync From xgboost parameter description : objective "binary:logistic: logistic regression for binary classification, output probability"

And in your question the mentioned num_class =12 ,this seems to be a mismatch as binary objective is used to predict variables belonging to 2 classes only (0/1).