Lev_ani
October 11, 2021, 11:47am
1
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?
seems odd...
what is the length of labels ?
how many rows in train?
and new_tr ?
I have handled this error already. There were some missing value in data, that was removed after model.matrix
and length of new_tr
was less than length of labels. I initially delete missing values and it works
system
Closed
October 19, 2021, 7:08am
4
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed. If you have a query related to it or one of the replies, start a new topic and refer back with a link.