I want to create xgb.Dmatrix
object. At the first step, I convert data.frame
into model.matrix
:
new_tr <- model.matrix(~.+0,data = train[,-c(21)])
labels <- train$default
and then write following code to create xgb.Dmatrix:
dtrain <- xgb.DMatrix(data = as.matrix(new_tr), label = labels)
I get following error:
Error in setinfo.xgb.DMatrix(dmat, names(p), p[[1]]) : The length of labels must equal to the number of rows in the input data
how to handle this problem?