{
  "id": 12293,
  "title": "Error using xgboost with multi:softprob objective",
  "url": "/competitions/datasciencebowl/discussion/12293",
  "author_name": "",
  "post_date": "2015-01-21T15:23:39.380Z",
  "votes": null,
  "comment_count": 2,
  "views": 4303,
  "content": "<p>I am trying to use the R package xgboost with the multi:softprob objective for this competition but each time RStudio crashes and gives he following error message.</p>\n<p>Error in xgb.iter.update(bst, dtrain, i-1, obj):</p>\n<p>&nbsp; SoftmaxxMultiClassObj: label exceed num_class</p>\n<p>Error in function(): SoftmaxMultiClassObj: label exceed num_class</p>\n\n<p>I set num_class =121 and the response variable (label) is a factor with 121 levels. So I don't understand where the error is coming from. Any ideas what is going on?&nbsp;</p>",
  "messages": [
    {
      "id": "62966",
      "postDate": "01/21/2015 15:23:39",
      "content": "<p>I am trying to use the R package xgboost with the multi:softprob objective for this competition but each time RStudio crashes and gives he following error message.</p>\n<p>Error in xgb.iter.update(bst, dtrain, i-1, obj):</p>\n<p>&nbsp; SoftmaxxMultiClassObj: label exceed num_class</p>\n<p>Error in function(): SoftmaxMultiClassObj: label exceed num_class</p>\n\n<p>I set num_class =121 and the response variable (label) is a factor with 121 levels. So I don't understand where the error is coming from. Any ideas what is going on?&nbsp;</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "62967",
      "postDate": "01/21/2015 15:39:54",
      "content": "<p>From memory, xgboost needs the labels to start at zero. So it might be worth checking if it works with labels from 0 to 120 rather than 1 to 121.</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "62969",
      "postDate": "01/21/2015 16:14:41",
      "content": "<p>Thanks it worked. I also needed to convert the response variable from factor to numeric.</p>",
      "rawMarkdown": "",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 62967,
      "author_name": "cartographic",
      "author_url": "",
      "post_date": "01/21/2015 15:39:54",
      "content": "<p>From memory, xgboost needs the labels to start at zero. So it might be worth checking if it works with labels from 0 to 120 rather than 1 to 121.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 62969,
      "author_name": "omoekan09",
      "author_url": "",
      "post_date": "01/21/2015 16:14:41",
      "content": "<p>Thanks it worked. I also needed to convert the response variable from factor to numeric.</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "62966": "",
    "62967": "",
    "62969": ""
  },
  "source": "meta"
}