Tuesday, December 22, 2015

XGBoost in R. Error in xgb.iter.update SoftmaxMultiClassObj

XGBoost in R. For regression, classification and ranking

Xgboost is short for eXtreme Gradient Boosting package, XGBoost includes regression, classification and ranking.

Install XGBoost latest version from github

devtools::install_github('dmlc/xgboost',subdir='R-package')


Error

clf<-xgboost(
 data=data.matrix(train[,feature.names]),
        label     = train$Survived,
 booster   = "gblinear",
 nrounds   = 20,
 objective = "multi:softprob",
 num_class = 2,
        eval_metric = "merror"
            )  
Error in xgb.iter.update(bst$handle, dtrain, i - 1, obj) : SoftmaxMultiClassObj: label must be in [0, num_class), num_class=2 but found 2 in label
Solution

needed to convert the response variable from factor to numeric.

train$Survived<-as.numeric(levels(train$Survived))[train$Survived]

also install package "libx11-dev"
solai@vm1$ sudo apt-get install libx11-dev

then try again.

Next :

1 comment:

Verify Customer Identity said...

At this point id verification service is really popular among persons. There are plenty of id verification methods that anybody can receive on a trustworthy site called Trust Swiftly, and a firm can utilize the methods to secure their own online business easily. By addressing this particular TRUSTSWIFTLY site, you can acquire more knowledge about id verification service.