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 :
Post a Comment