{"action":"closed","issue":{"url":"https://api.github.com/repos/dmlc/xgboost/issues/726","labels_url":"https://api.github.com/repos/dmlc/xgboost/issues/726/labels{/name}","comments_url":"https://api.github.com/repos/dmlc/xgboost/issues/726/comments","events_url":"https://api.github.com/repos/dmlc/xgboost/issues/726/events","html_url":"https://github.com/dmlc/xgboost/issues/726","id":125341992,"number":726,"title":"early.stop.round does not work properly","user":{"login":"ganesh-krishnan","id":7553194,"avatar_url":"https://avatars.githubusercontent.com/u/7553194?v=3","gravatar_id":"","url":"https://api.github.com/users/ganesh-krishnan","html_url":"https://github.com/ganesh-krishnan","followers_url":"https://api.github.com/users/ganesh-krishnan/followers","following_url":"https://api.github.com/users/ganesh-krishnan/following{/other_user}","gists_url":"https://api.github.com/users/ganesh-krishnan/gists{/gist_id}","starred_url":"https://api.github.com/users/ganesh-krishnan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ganesh-krishnan/subscriptions","organizations_url":"https://api.github.com/users/ganesh-krishnan/orgs","repos_url":"https://api.github.com/users/ganesh-krishnan/repos","events_url":"https://api.github.com/users/ganesh-krishnan/events{/privacy}","received_events_url":"https://api.github.com/users/ganesh-krishnan/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-01-07T07:34:23Z","updated_at":"2016-01-15T05:17:25Z","closed_at":"2016-01-15T05:17:25Z","body":"early.stop.round does not work if only one metric is provided. In fact, it seems like early.stop.round does not use the first metric for stopping when two metrics are provided. The source of both errors appears to be the same line of code.\r\n\r\n```r\r\ndata(agaricus.train, package='xgboost')\r\ndtrain <- xgb.DMatrix(agaricus.train$data, label = agaricus.train$label)\r\nhistory <- xgb.cv(data = dtrain, nround=3, nthread = 2, nfold = 5, metrics=list(\"rmse\"),\r\n                  max.depth =3, eta = 1, objective = \"binary:logistic\", early.stop.round=3)\r\n```\r\n\r\nThis results in the following error:\r\n> Error in strsplit(score, \"\\\\+|:\")[[1]][[2]] : subscript out of bounds\r\n\r\nThe issue seems to be the following line of code in xgb.cv:\r\n\r\n```r\r\n score = strsplit(ret, \"\\\\s+\")[[1]][1 + length(metrics) + 2]\r\n```\r\n\r\nChanging that line to the following should fix it.\r\n\r\n```r\r\nscore = strsplit(ret, \"\\\\s+\")[[1]][2 + length(metrics)]\r\n```\r\n\r\n\r\n\r\n"}}