python: multiple eval_metrics changes
- allows feval to return a list of tuples (name, error/score value) - changed behavior for multiple eval_metrics in conjunction with early_stopping: Instead of raising an error, the last passed evel_metric (or last entry in return value of feval) is used for early stopping - allows list of eval_metrics in dict-typed params - unittest for new features / behavior documentation updated - example for assigning a list to 'eval_metric' - note about early stopping on last passed eval metric - info msg for used eval metric added
This commit is contained in:
@@ -67,10 +67,17 @@ XGBoost use list of pair to save [parameters](../parameter.md). Eg
|
||||
```python
|
||||
param = {'bst:max_depth':2, 'bst:eta':1, 'silent':1, 'objective':'binary:logistic' }
|
||||
param['nthread'] = 4
|
||||
plst = param.items()
|
||||
plst += [('eval_metric', 'auc')] # Multiple evals can be handled in this way
|
||||
plst += [('eval_metric', 'ams@0')]
|
||||
param['eval_metric'] = 'auc'
|
||||
```
|
||||
* You can also specify multiple eval metrics:
|
||||
```python
|
||||
param['eval_metric'] = ['auc', 'ams@0']
|
||||
|
||||
# alternativly:
|
||||
# plst = param.items()
|
||||
# plst += [('eval_metric', 'ams@0')]
|
||||
```
|
||||
|
||||
* Specify validations set to watch performance
|
||||
```python
|
||||
evallist = [(dtest,'eval'), (dtrain,'train')]
|
||||
@@ -116,7 +123,7 @@ The model will train until the validation score stops improving. Validation erro
|
||||
|
||||
If early stopping occurs, the model will have two additional fields: `bst.best_score` and `bst.best_iteration`. Note that `train()` will return a model from the last iteration, not the best one.
|
||||
|
||||
This works with both metrics to minimize (RMSE, log loss, etc.) and to maximize (MAP, NDCG, AUC).
|
||||
This works with both metrics to minimize (RMSE, log loss, etc.) and to maximize (MAP, NDCG, AUC). Note that if you specify more than one evaluation metric the last one in `param['eval_metric']` is used for early stopping.
|
||||
|
||||
Prediction
|
||||
----------
|
||||
|
||||
Reference in New Issue
Block a user