title: XGBoost predict function return more than size of target variable in r
body: <p>I made the XGBoost model and when I try to run the predict function it return a vector with more than the size of target column in test dataset. 
  Both train and test include the same categories of the target variable. Categories have the values of 0 to 7, so numerical and starting from 0. 
  I tried different case studies as a pattern but the problem remains. Can you help  me to figure out what is causing this issue?</p>
  
  <pre><code>&gt; head(train, 3)
         a      b    c   y  d   e
   1: 3.0148 4.4982  64  5  23  3
   2: 3.0011 4.4465  71  1  20  3
   3: 3.0084 4.4347  72  1  16  5
   ....
  # 37 rows in train and 15 rows in test 
  # store the target column of test and train data before deletion.
  y.train &lt;- train$y
  y.test &lt;- test$y
  # remove target column
  train &lt;- select(train, -y)
  test &lt;- select(test, -y)
  # change to matrix
  trainMatrix &lt;- as.matrix(train)
  testMatrix &lt;- as.matrix(test)
  #find number of classes 
  numberOfClasses &lt;- unique(y.train) %&gt;% length()
  # XGBoost parameter set and run
  param &lt;- list("objective" = "multi:softprob",
            "eval_metric" = "mlogloss",
            "num_class" = numberOfClasses)
  bst = xgboost(param=param, data = trainMatrix, label = y.train, nrounds=15)
  #make the prediction
  y_pred &lt;- predict(bst, testMatrix)
  length(y_pred) # returns 105 while there are only 15 rows in test data
  </code></pre>