Commit 922013b0 authored by Peter's avatar Peter Committed by Guolin Ke
Browse files

fix cv metrics bug (#476)

parent 8a19834a
......@@ -556,8 +556,9 @@ The methods of each Class is in alphabetical order.
Perform stratified sampling.
shuffle: bool
Whether shuffle before split data.
metrics : str or list of str
metrics : str or list of str, default None
Evaluation metrics to be watched in CV.
If `metrics` is not None, the metric in `params` will be overridden.
fobj : function
Custom objective function.
feval : function
......
......@@ -314,6 +314,7 @@ def cv(params, train_set, num_boost_round=10,
Whether shuffle before split data
metrics : string or list of strings
Evaluation metrics to be watched in CV.
If `metrics` is not None, the metric in `params` will be overridden.
fobj : function
Custom objective function.
feval : function
......@@ -368,12 +369,8 @@ def cv(params, train_set, num_boost_round=10,
train_set.set_feature_name(feature_name)
train_set.set_categorical_feature(categorical_feature)
if metrics:
params.setdefault('metric', [])
if isinstance(metrics, string_type):
params['metric'].append(metrics)
else:
params['metric'].extend(metrics)
if metrics is not None:
params['metric'] = metrics
results = collections.defaultdict(list)
cvfolds = _make_n_folds(train_set, data_splitter=data_splitter,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment