{"action":"created","issue":{"url":"https://api.github.com/repos/dmlc/xgboost/issues/290","labels_url":"https://api.github.com/repos/dmlc/xgboost/issues/290/labels{/name}","comments_url":"https://api.github.com/repos/dmlc/xgboost/issues/290/comments","events_url":"https://api.github.com/repos/dmlc/xgboost/issues/290/events","html_url":"https://github.com/dmlc/xgboost/issues/290","id":73747428,"number":290,"title":"Memory allocation error with Caret Wrapper","user":{"login":"larry77","id":502614,"avatar_url":"https://avatars.githubusercontent.com/u/502614?v=3","gravatar_id":"","url":"https://api.github.com/users/larry77","html_url":"https://github.com/larry77","followers_url":"https://api.github.com/users/larry77/followers","following_url":"https://api.github.com/users/larry77/following{/other_user}","gists_url":"https://api.github.com/users/larry77/gists{/gist_id}","starred_url":"https://api.github.com/users/larry77/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/larry77/subscriptions","organizations_url":"https://api.github.com/users/larry77/orgs","repos_url":"https://api.github.com/users/larry77/repos","events_url":"https://api.github.com/users/larry77/events{/privacy}","received_events_url":"https://api.github.com/users/larry77/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-05-06T21:48:02Z","updated_at":"2015-05-08T13:05:48Z","closed_at":null,"body":"The following script causes the a memory allocation error when you let it run long enough.\r\nThe train. csv data can be downloaded from the otto classification\r\n\r\n http://bit.ly/1I2bauw\r\n\r\n```r\r\nlibrary(readr)\r\nlibrary(xgboost)\r\nlibrary(caret)\r\n\r\nmodelInfo <- list(label = \"eXtreme Gradient Boosting\",\r\n                  library = c(\"xgboost\", \"plyr\"),\r\n                  type = c(\"Regression\", \"Classification\"),\r\n                  parameters = data.frame(parameter = c('nrounds', 'max_depth', 'eta'),\r\n                                          class = rep(\"numeric\", 3),\r\n                                          label = c('# Boosting Iterations', 'Max Tree Depth', \r\n                                                    'Shrinkage')),\r\n                  grid = function(x, y, len = NULL) expand.grid(max_depth = seq(1, len),\r\n                                                                nrounds = floor((1:len) * 50),\r\n                                                                eta = .3),\r\n                  loop = function(grid) {     \r\n                    loop <- ddply(grid, c(\"eta\", \"max_depth\"),\r\n                                  function(x) c(nrounds = max(x$nrounds)))\r\n                    submodels <- vector(mode = \"list\", length = nrow(loop))\r\n                    for(i in seq(along = loop$nrounds)) {\r\n                      index <- which(grid$max_depth == loop$max_depth[i] & \r\n                                       grid$eta == loop$eta[i])\r\n                      trees <- grid[index, \"nrounds\"] \r\n                      submodels[[i]] <- data.frame(nrounds = trees[trees != loop$nrounds[i]])\r\n                    }    \r\n                    list(loop = loop, submodels = submodels)\r\n                  },\r\n                  fit = function(x, y, wts, param, lev, last, classProbs, ...) { \r\n                    if(is.factor(y)) {\r\n                      if(length(lev) == 2) {\r\n                        y <- ifelse(y == lev[1], 1, 0) \r\n                        dat <- xgb.DMatrix(as.matrix(x), label = y)\r\n                        out <- xgb.train(list(eta = param$eta, \r\n                                              max_depth = param$max_depth), \r\n                                         data = dat,\r\n                                         nrounds = param$nrounds,\r\n                                         objective = \"binary:logistic\",\r\n                                         ...)\r\n                      } else {\r\n                        y <- as.numeric(y) - 1\r\n                        dat <- xgb.DMatrix(as.matrix(x), label = y)\r\n                        out <- xgb.train(list(eta = param$eta, \r\n                                              max_depth = param$max_depth), \r\n                                         data = dat,\r\n                                         num_class = length(lev),\r\n                                         nrounds = param$nrounds,\r\n                                         objective = \"multi:softprob\",\r\n                                         ...)\r\n                      }     \r\n                    } else {\r\n                      dat <- xgb.DMatrix(as.matrix(x), label = y)\r\n                      out <- xgb.train(list(eta = param$eta, \r\n                                            max_depth = param$max_depth), \r\n                                       data = dat,\r\n                                       nrounds = param$nrounds,\r\n                                       objective = \"reg:linear\",\r\n                                       ...)\r\n                    }\r\n                    out\r\n                  },\r\n   predict = function(modelFit, newdata, submodels = NULL) {\r\n                    newdata <- xgb.DMatrix(as.matrix(newdata))\r\n                    out <- predict(modelFit, newdata)\r\n                    if(modelFit$problemType == \"Classification\") {\r\n                      if(length(modelFit$obsLevels) == 2) {\r\n                        out <- ifelse(out >= .5, \r\n                                      modelFit$obsLevels[1], \r\n                                      modelFit$obsLevels[2])\r\n                      } else {\r\n                        out <- matrix(out, ncol = length(modelFit$obsLevels), byrow = TRUE)\r\n                        out <- modelFit$obsLevels[apply(out, 1, which.max)]\r\n                      }\r\n                    }\r\n  if(!is.null(submodels)) {\r\n                      tmp <- vector(mode = \"list\", length = nrow(submodels) + 1)\r\n                      tmp[[1]] <- out\r\n                      for(j in seq(along = submodels$nrounds)) {\r\n                        tmp_pred <- predict(modelFit, newdata, ntreelimit = submodels$nrounds[j])\r\n                        if(modelFit$problemType == \"Classification\") {\r\n                          if(length(modelFit$obsLevels) == 2) {\r\n                            tmp_pred <- ifelse(tmp_pred >= .5, \r\n                                               modelFit$obsLevels[1], \r\n                                               modelFit$obsLevels[2])\r\n                          } else {\r\n                            tmp_pred <- matrix(tmp_pred, ncol = length(modelFit$obsLevels), byrow = TRUE)\r\n                            tmp_pred <- modelFit$obsLevels[apply(tmp_pred, 1, which.max)]\r\n                          }\r\n                        }\r\n                        tmp[[j+1]]  <- tmp_pred\r\n                      }\r\n                      out <- tmp\r\n                    }\r\n                    out  \r\n                  },\r\n                  prob = function(modelFit, newdata, submodels = NULL) {\r\n                    newdata <- xgb.DMatrix(as.matrix(newdata))\r\n                    out <- predict(modelFit, newdata)\r\n                    if(length(modelFit$obsLevels) == 2) {\r\n                      out <- cbind(out, 1 - out)\r\n                      colnames(out) <- modelFit$obsLevels\r\n                    } else {\r\n                      out <- matrix(out, ncol = length(modelFit$obsLevels), byrow = TRUE)\r\n                      colnames(out) <- modelFit$obsLevels\r\n                    }\r\n                    out <- as.data.frame(out)\r\n                    if(!is.null(submodels)) {\r\n                      tmp <- vector(mode = \"list\", length = nrow(submodels) + 1)\r\n                      tmp[[1]] <- out\r\n                      for(j in seq(along = submodels$nrounds)) {\r\n                        tmp_pred <- predict(modelFit, newdata, ntreelimit = submodels$nrounds[j])\r\n                        if(length(modelFit$obsLevels) == 2) {\r\n                          tmp_pred <- cbind(tmp_pred, 1 - tmp_pred)\r\n                          colnames(tmp_pred) <- modelFit$obsLevels\r\n                        } else {\r\n                          tmp_pred <- matrix(tmp_pred, ncol = length(modelFit$obsLevels), byrow = TRUE)\r\n                          colnames(tmp_pred) <- modelFit$obsLevels\r\n                        }\r\n                        tmp_pred <- as.data.frame(tmp_pred)\r\n                        tmp[[j+1]]  <- tmp_pred\r\n                      }\r\n                      out <- tmp\r\n                    }\r\n                    out  \r\n                  },\r\n                  predictors = function(x, ...) {\r\n                    imp <- xgb.importance(x$xNames, model = x)\r\n                    x$xNames[x$xNames %in% imp$Feature]\r\n                  },\r\n                  varImp = function(object, numTrees = NULL, ...) {\r\n                    imp <- xgb.importance(x$xNames, model = x)\r\n                    imp <- as.data.frame(imp)[, 1:2]\r\n                    rownames(imp) <- as.character(imp[,1])\r\n                    imp <- imp[,2,drop = FALSE]\r\n                    colnames(imp) <- \"Overall\"\r\n                    imp   \r\n                  },\r\n                  levels = function(x) x$obsLevels,\r\n                  tags = c(\"Tree-Based Model\", \"Boosting\", \"Ensemble Model\", \"Implicit Feature Selection\"),\r\n                  sort = function(x) {\r\n                    # This is a toss-up, but the # trees probably adds\r\n                    # complexity faster than number of splits\r\n                    x[order(x$nrounds, x$max_depth, x$eta),] \r\n                  })\r\n\r\n\r\ntrain <- read_csv(\"train.csv\")\r\n\r\ntrain$target <- as.factor(train$target)\r\ngrid <- expand.grid(nrounds = seq(26, 406, by = 20),\r\n                    max_depth = 5:17,\r\n                    eta = c(seq(0.01,0.31,by=0.05)))\r\nmod1 <- train(target~.,data=train,\r\n              method = modelInfo,\r\n              tuneGrid = grid,  nthread=10,\r\n              verbose=T,\r\n              trControl = trainControl(method = \"repeatedcv\" , number=10,\r\n                  repeats=10,\r\n                  classProbs = TRUE, verbose=T)  )\r\n\r\n\r\n\r\nsaveRDS(mod1, \"caret-xgboost-otto.RDS\")\r\n```\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/dmlc/xgboost/issues/comments/100226125","html_url":"https://github.com/dmlc/xgboost/issues/290#issuecomment-100226125","issue_url":"https://api.github.com/repos/dmlc/xgboost/issues/290","id":100226125,"user":{"login":"larry77","id":502614,"avatar_url":"https://avatars.githubusercontent.com/u/502614?v=3","gravatar_id":"","url":"https://api.github.com/users/larry77","html_url":"https://github.com/larry77","followers_url":"https://api.github.com/users/larry77/followers","following_url":"https://api.github.com/users/larry77/following{/other_user}","gists_url":"https://api.github.com/users/larry77/gists{/gist_id}","starred_url":"https://api.github.com/users/larry77/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/larry77/subscriptions","organizations_url":"https://api.github.com/users/larry77/orgs","repos_url":"https://api.github.com/users/larry77/repos","events_url":"https://api.github.com/users/larry77/events{/privacy}","received_events_url":"https://api.github.com/users/larry77/received_events","type":"User","site_admin":false},"created_at":"2015-05-08T13:05:48Z","updated_at":"2015-05-08T13:05:48Z","body":"On Thu, May 07, 2015 at 10:39:09PM -0700, Tianqi Chen wrote:\n>Can you try to provide an simplified case to reproduce the error faster?\n>Currently I cannot tell the cause of error and seems I could not reproduce it on my machine.\n> For example, try to reduce numrounds in the tuning parameter\n>\n>Thanks\n>\n\nHi,\nI wish it was that easy. When the model is small (i.e. not many grid\nvalues and not many iterations), then it completes successfully (I\npaste at the end of the email an example which runs without a glitch\nand should take 3-4\nminutes on a laptop). However, in the full scale simulation\nthat I emailed you, it breaks down after some time on a workstation\nwith a segmentation fault error message.\nI have not yet been able to reproduce the error with a small toy\nmodel.\n\nLorenzo\n\n###############################################################################################\n\n\nlibrary(readr)\nlibrary(xgboost)\nlibrary(caret)\n\nmodelInfo <- list(label = \"eXtreme Gradient Boosting\",\n                  library = c(\"xgboost\", \"plyr\"),\n\t\t                    type = c(\"Regression\",\n                  \"Classification\"),\n\t\t                    parameters = data.frame(parameter\n                  = c('nrounds', 'max_depth', 'eta'),\n\t\t                                            class =\n                  rep(\"numeric\", 3),\n\t\t                                            label =\n                  c('# Boosting Iterations', 'Max Tree Depth',\n\t\t                                                      'Shrinkage')),\n\t\t\t\t\t\t\t\t                        grid\n                  = function(x, y, len = NULL) expand.grid(max_depth =\n                  seq(1, len),\n\t\t                                                                  nrounds\n                  = floor((1:len) * 50),\n\t\t                                                                  eta\n                  = .3),\n\t\t                    loop = function(grid) {\n\t\t\t\t                        loop <-\n                  ddply(grid, c(\"eta\", \"max_depth\"),\n\t\t                                    function(x)\n                  c(nrounds = max(x$nrounds)))\n\t\t                      submodels <- vector(mode =\n                  \"list\", length = nrow(loop))\n\t\t                      for(i in seq(along =\n                  loop$nrounds)) {\n\t\t                        index <- which(grid$max_depth\n                  == loop$max_depth[i] &\n\t\t                                         grid$eta ==\n                  loop$eta[i])\n\t\t                        trees <- grid[index,\n                  \"nrounds\"]\n\t\t                        submodels[[i]] <-\n                  data.frame(nrounds = trees[trees !=\n                  loop$nrounds[i]])\n\t\t                      }\n\t\t\t\t                          list(loop =\n                  loop, submodels = submodels)\n\t\t                    },\n\t\t\t\t                      fit =\n                  function(x, y, wts, param, lev, last, classProbs,\n                  ...) {\n\t\t                      if(is.factor(y)) {\n\t\t\t\t                            if(length(lev)\n                  == 2) {\n\t\t                          y <- ifelse(y == lev[1], 1,\n                  0)\n\t\t                          dat <-\n                  xgb.DMatrix(as.matrix(x), label = y)\n\t\t                          out <- xgb.train(list(eta =\n                  param$eta,\n\t\t                                                max_depth\n                  = param$max_depth),\n\t\t                                           data = dat,\n\t\t\t\t\t\t\t                                            nrounds\n                  = param$nrounds,\n\t\t                                           objective =\n                  \"binary:logistic\",\n\t\t                                           ...)\n\t\t\t\t\t\t\t                         }\n                  else {\n\t\t                          y <- as.numeric(y) - 1\n\t\t\t\t\t                          dat\n                  <- xgb.DMatrix(as.matrix(x), label = y)\n\t\t                          out <- xgb.train(list(eta =\n                  param$eta,\n\t\t                                                max_depth\n                  = param$max_depth),\n\t\t                                           data = dat,\n\t\t\t\t\t\t\t                                            num_class\n                  = length(lev),\n\t\t                                           nrounds =\n                  param$nrounds,\n\t\t                                           objective =\n                  \"multi:softprob\",\n\t\t                                           ...)\n\t\t\t\t\t\t\t                         }\n\t\t\t\t\t\t\t\t\t\t                     }\n                  else {\n\t\t                        dat <-\n                  xgb.DMatrix(as.matrix(x), label = y)\n\t\t                        out <- xgb.train(list(eta =\n                  param$eta,\n\t\t                                              max_depth\n                  = param$max_depth),\n\t\t                                         data = dat,\n\t\t\t\t\t\t\t                                        nrounds\n                  = param$nrounds,\n\t\t                                         objective =\n                  \"reg:linear\",\n\t\t                                         ...)\n\t\t\t\t\t\t\t                     }\n\t\t\t\t\t\t\t\t\t                         out\n\n\n                  },\n\t\t                    predict = function(modelFit,\n\t\t                    newdata, submodels = NULL) {\n\t\t\t\t                        newdata <-\n\t\t                    xgb.DMatrix(as.matrix(newdata))\n\t\t\t\t                        out <-\n\t\t                    predict(modelFit, newdata)\n\t\t\t\t                        if(modelFit$problemType\n\t\t                    == \"Classification\") {\n\t\t\t\t                          if(length(modelFit$obsLevels)\n\t\t                    == 2) {\n\t\t\t\t                            out <-\n\t\t                    ifelse(out >= .5,\n\t\t\t\t                                          modelFit$obsLevels[1],\n\t\t\t\t\t\t\t\t\t                                        modelFit$obsLevels[2])\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t                      }\n\t\t                    else {\n\t\t\t\t                            out <-\n\t\t                    matrix(out, ncol =\n\t\t                    length(modelFit$obsLevels), byrow\n\t\t                    = TRUE)\n\t\t\t\t                            out <-\n\t\t                    modelFit$obsLevels[apply(out, 1,\n\t\t                    which.max)]\n\t\t\t\t                          }\n\t\t\t\t\t\t\t                      }\n\n                    if(!is.null(submodels)) {\n\t\t                          tmp <- vector(mode = \"list\",\n\t\t                          length = nrow(submodels) +\n\t\t                          1)\n\t\t\t\t\t                        tmp[[1]]\n\t\t                          <- out\n\t\t\t\t\t                        for(j\n\t\t                          in seq(along =\n\t\t                          submodels$nrounds)) {\n\t\t\t\t\t                          tmp_pred\n\t\t                          <- predict(modelFit,\n\t\t                          newdata, ntreelimit =\n\t\t                          submodels$nrounds[j])\n\t\t\t\t\t                          if(modelFit$problemType\n\t\t                          == \"Classification\") {\n\t\t\t\t\t                            if(length(modelFit$obsLevels)\n\t\t                          == 2) {\n\t\t\t\t\t                              tmp_pred\n\t\t                          <- ifelse(tmp_pred >= .5,\n\t\t\t\t\t                                                 modelFit$obsLevels[1],\n\t\t\t\t\t\t\t\t\t\t\t                                                modelFit$obsLevels[2])\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t                          }\n\t\t                          else {\n\t\t\t\t\t                              tmp_pred\n\t\t                          <- matrix(tmp_pred, ncol =\n\t\t                          length(modelFit$obsLevels),\n\t\t                          byrow = TRUE)\n\t\t\t\t\t                              tmp_pred\n\t\t                          <-\n\t\t                          modelFit$obsLevels[apply(tmp_pred,\n\t\t                          1, which.max)]\n\t\t\t\t\t                            }\n\t\t\t\t\t\t\t\t                            }\n\t\t\t\t\t\t\t\t\t\t\t                            tmp[[j+1]]\n\t\t                          <- tmp_pred\n\t\t\t\t\t                        }\n\t\t\t\t\t\t\t\t                      out\n\t\t                          <- tmp\n\t\t\t\t\t                      }\n\t\t\t\t\t\t\t                          out\n\t\t\t\t\t\t\t\t\t\t                    },\n\t\t\t\t\t\t\t\t\t\t\t\t                      prob\n\t\t                          = function(modelFit,\n\t\t                          newdata, submodels = NULL) {\n\t\t\t\t\t                      newdata\n\t\t                          <-\n\t\t                          xgb.DMatrix(as.matrix(newdata))\n\t\t\t\t\t                      out <-\n\t\t                          predict(modelFit, newdata)\n\t\t\t\t\t                      if(length(modelFit$obsLevels)\n\t\t                          == 2) {\n\t\t\t\t\t                        out <-\n\t\t                          cbind(out, 1 - out)\n\t\t\t\t\t                        colnames(out)\n\t\t                          <- modelFit$obsLevels\n\t\t\t\t\t                      } else {\n\t\t\t\t\t\t\t                            out\n\t\t                          <- matrix(out, ncol =\n\t\t                          length(modelFit$obsLevels),\n\t\t                          byrow = TRUE)\n\t\t\t\t\t                        colnames(out)\n\t\t                          <- modelFit$obsLevels\n\t\t\t\t\t                      }\n\t\t\t\t\t\t\t                          out\n\t\t                          <- as.data.frame(out)\n\n                    if(!is.null(submodels)) {\n\t\t                          tmp <- vector(mode = \"list\",\n\t\t                          length = nrow(submodels) +\n\t\t                          1)\n\t\t\t\t\t                        tmp[[1]]\n\t\t                          <- out\n\t\t\t\t\t                        for(j\n\t\t                          in seq(along =\n\t\t                          submodels$nrounds)) {\n\t\t\t\t\t                          tmp_pred\n\t\t                          <- predict(modelFit,\n\t\t                          newdata, ntreelimit =\n\t\t                          submodels$nrounds[j])\n\t\t\t\t\t                          if(length(modelFit$obsLevels)\n\t\t                          == 2) {\n\t\t\t\t\t                            tmp_pred\n\t\t                          <- cbind(tmp_pred, 1 -\n\t\t                          tmp_pred)\n\t\t\t\t\t                            colnames(tmp_pred)\n\t\t                          <- modelFit$obsLevels\n\t\t\t\t\t                          }\n\t\t                          else {\n\t\t\t\t\t                            tmp_pred\n\t\t                          <- matrix(tmp_pred, ncol =\n\t\t                          length(modelFit$obsLevels),\n\t\t                          byrow = TRUE)\n\t\t\t\t\t                            colnames(tmp_pred)\n\t\t                          <- modelFit$obsLevels\n\t\t\t\t\t                          }\n\t\t\t\t\t\t\t\t                          tmp_pred\n\t\t                          <- as.data.frame(tmp_pred)\n\t\t\t\t\t                          tmp[[j+1]]\n\t\t                          <- tmp_pred\n\t\t\t\t\t                        }\n\t\t\t\t\t\t\t\t                      out\n\t\t                          <- tmp\n\t\t\t\t\t                      }\n\t\t\t\t\t\t\t                          out\n\t\t\t\t\t\t\t\t\t\t                    },\n\t\t\t\t\t\t\t\t\t\t\t\t                      predictors\n\t\t                          = function(x, ...) {\n\t\t\t\t\t                      imp <-\n\t\t                          xgb.importance(x$xNames,\n\t\t                          model = x)\n\t\t\t\t\t                      x$xNames[x$xNames\n\t\t                          %in% imp$Feature]\n\t\t\t\t\t                    },\n\t\t\t\t\t\t\t                      varImp\n\t\t                          = function(object, numTrees\n\t\t                          = NULL, ...) {\n\t\t\t\t\t                      imp <-\n\t\t                          xgb.importance(x$xNames,\n\t\t                          model = x)\n\t\t\t\t\t                      imp <-\n\t\t                          as.data.frame(imp)[, 1:2]\n\t\t\t\t\t                      rownames(imp)\n\t\t                          <- as.character(imp[,1])\n\t\t\t\t\t                      imp <-\n\t\t                          imp[,2,drop = FALSE]\n\t\t\t\t\t                      colnames(imp)\n\t\t                          <- \"Overall\"\n\t\t\t\t\t                      imp\n\t\t\t\t\t\t\t                        },\n\t\t\t\t\t\t\t\t\t\t                  levels\n\t\t                          = function(x) x$obsLevels,\n\t\t\t\t\t                    tags =\n\t\t                          c(\"Tree-Based Model\",\n\t\t                          \"Boosting\", \"Ensemble\n\t\t                          Model\", \"Implicit Feature\n\t\t                          Selection\"),\n\t\t\t\t\t                    sort =\n\t\t                          function(x) {\n\t\t\t\t\t                      # This\n\t\t                          is a toss-up, but the #\n\t\t                          trees probably adds\n\t\t\t\t\t                      #\n\t\t                          complexity faster than\n\t\t                          number of splits\n\t\t\t\t\t                      x[order(x$nrounds,\n\t\t                          x$max_depth, x$eta),]\n\t\t\t\t\t                    })\n\n\n#####################################################\n#####################################################\n#####################################################\n\n\n## param <- list(\"objective\" = \"multi:softprob\",\n##               \"max_depth\"=12,\n##               \"eta\"=0.1,\n##               \"subsample\"=0.7,\n##               \"colsample_bytree\"= 1,\n##               \"gamma\"=2,\n##                \"min_child_weight\"=4,\n##               \"eval_metric\" = \"mlogloss\",\n##                \"min_child_weight\"=2,\n##               ## \"silent\"=1,\n##               \"num_class\" = 9,\n##               \"nthread\" = threads)\n\n\n\n\n\n\ntrain <- read_csv(\"train.csv\")\n\ntrain$target <- as.factor(train$target)\n\n## x <- subset(train, select=-c(target))\n\n## x <- as.matrix(x)\n## x = matrix(as.numeric(x),nrow(x),ncol(x)) ## now x is a matrix of\n## purely numerical values\n\n\n## y <- train$target\n## y <- as.factor(y)\n\n## y = gsub('Class_','',y)\n## y = as.integer(y)-1 #xgboost take features in [0,numOfClass)\n## In other words: y is now a numeric vector in 0...(numOfClass-1)\n\n\ngrid <- expand.grid(nrounds = seq(1, 11, by = 10),\n                    max_depth = seq(5,15,by=5),\n\t\t                        eta =\n                    c(seq(0.01,0.31,by=0.1)))\n\n\n## grid <- expand.grid(nrounds = c(10),\n##                     max_depth = 5:6,\n##                     eta = c(seq(0.01,0.06,by=0.05)))\n\n\nmod1 <- train(target~.,data=train,\n              method = modelInfo,\n\t                    tuneGrid = grid,  nthread=2,\n\t\t\t                  verbose=T,\n\t\t\t\t\t                trControl =\n              trainControl(method = \"repeatedcv\" , number=2,\n\t                        repeats=2,\n\t\t\t\t                  classProbs = TRUE,\n              verbose=T)  )\n\n\n\nsaveRDS(mod1, \"caret-xgboost-otto.RDS\")\n\n\n\n\n\n>---\n>Reply to this email directly or view it on GitHub:\n>https://github.com/dmlc/xgboost/issues/290#issuecomment-100106919\n"}}