How to remove single row from xgb.DMatrix

Viewed 469

I have a xgb.DMatrix with 42 rows and 50 features. I would like to remove a single row (let say row 5) and create a new DMatrix in this way containing 41 rows. I can easily do this when working with a normal matrix using e.g.

myMatrix<— matrix(c(1:50),nrow=5)
subMatrix<—myMatrix[-5,]

However, when I convert myMatrix with xgb.DMatrix the above approach doesn’t work.

I have tried to use the "slice" command but am not sure how to remove only a single row which is not necessary the first or the last one.

0 Answers
Related