@hackers wrote:
Hello,
I am trying to implement xgboost in R for a classification problem:
# xgboost parameters param <- list("objective" = "binary:logistic", # binary classification "eval_metric" = "error", # evaluation metric "nthread" = 8, # number of threads to be used "max_depth" = 16, # maximum depth of tree "eta" = 0.2, # step size shrinkage "gamma" = 0, # minimum loss reduction "subsample" = 1, # part of data instances to grow tree "colsample_bytree" = 1, # subsample ratio of columns when constructing each tree "min_child_weight" = 12) # minimum sum of instance weight needed in a child # Split back into test and train sets train_xg <- combi_fg[1:891,] test_xg <- combi_fg[892:1309,] #Convert the data to matrix form: #Convert the train_xg: train.matrix = as.matrix(train_xg) mode(train.matrix) = "numeric" #Convert the test_xg:s test.matrix = as.matrix(test_xg) mode(test.matrix) = "numeric" # k-fold cross validation, with timing nround.cv = 200 xgboost.cv <- xgb.cv(param=param, data=train.matrix, label=train$Survived, nfold=10, nrounds=nround.cv, prediction=TRUE, verbose=T)
However when I am trying to predict on the test data using:
pred <- predict(xgboost.cv,test.matrix)
I am getting an error:
Why is this error coming and how to resolve it??
Posts: 2
Participants: 2