Skip to content

Commit

Permalink
Fix dmlc#4630, dmlc#4421: Preserve correct ordering between metrics, …
Browse files Browse the repository at this point in the history
…and always use last metric for early stopping
  • Loading branch information
hcho3 committed Jul 4, 2019
1 parent 4e9fad7 commit 5c3d45f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions python-package/xgboost/training.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,16 +352,16 @@ def aggcv(rlist):
for line in rlist:
arr = line.split()
assert idx == arr[0]
for it in arr[1:]:
for metric_idx, it in enumerate(arr[1:]):
if not isinstance(it, STRING_TYPES):
it = it.decode()
k, v = it.split(':')
if k not in cvmap:
cvmap[k] = []
cvmap[k].append(float(v))
if (metric_idx, k) not in cvmap:
cvmap[(metric_idx, k)] = []
cvmap[(metric_idx, k)].append(float(v))
msg = idx
results = []
for k, v in sorted(cvmap.items(), key=lambda x: (x[0].startswith('test'), x[0])):
for (metric_idx, k), v in sorted(cvmap.items(), key=lambda x: x[0][0]):
v = np.array(v)
if not isinstance(msg, STRING_TYPES):
msg = msg.decode()
Expand Down

0 comments on commit 5c3d45f

Please sign in to comment.