How to create confusion matrix for xgboost in R




I am using the below code for xgboost: <-, data=data.matrix(X[,-1]), label=y, 
                        nfold=10,, 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??


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:



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.