How to create confusion matrix for xgboost in R

r
xgboost
confusion_matrix

#1

Hello,

I am using the below code for xgboost:

bst.cv <- xgb.cv(param=param, data=data.matrix(X[,-1]), label=y, 
                        nfold=10, nrounds=nround.cv, prediction=TRUE, verbose=FALSE)

I came across the below piece of code somewhere to calculate cf:

But when I try apply this I get an error:

Can someone please help me on how to resolve this??


#2

Hi @hackers

I think I got your problem not sure, iMac.col() with start at 1 and your y at ?? 0 not so sure I think you start at 1 or higher.

Let me know if I right I am curious :slightly_smiling:

Alain


#3

This error pops up mostly when some of your data variable show zero variance.
you need to remove those variables and may be some variable contain same values.