title: Xgboost error : label must be in [0, num_class), num_class=2
body: <p>Getting this error while implementing XGboost for the titanic problem</p>
  
  <blockquote>
    <p>Error in xgb.iter.update(bst$handle, dtrain, iteration - 1, obj) :<br>
    [03:26:03] amalgamation/../src/objective/multiclass_obj.cc:75: Check
    failed: label_error >= 0 &amp;&amp; label_error &lt; nclass SoftmaxMultiClassObj:
    label must be in [0, num_class), num_class=2 but found 2 in label.</p>
  </blockquote>
  
  <p><strong>Following is my code:</strong></p>
  
  <pre><code>#Parameter  ie no of class
  nc &lt;- length(unique(train_label))
  nc
  xgb_params &lt;- list("objective"="multi:softprob",
                         "eval_metric"="mlogloss",
                         "num_class"=nc)
  watchlist &lt;- list(train=train_matix,test=test_matix)
  
  
  #XGB Model
  bst_model &lt;- xgb.train(params = xgb_params,data = train_matix, nrounds = 100,watchlist = watchlist)
  </code></pre>
  
  <p>How can I resolve this?</p>