Let XGBoostError inherit ValueError. (#5696)
This commit is contained in:
parent
8438c7d0e4
commit
f145241593
@ -26,7 +26,7 @@ from .libpath import find_lib_path
|
|||||||
c_bst_ulong = ctypes.c_uint64
|
c_bst_ulong = ctypes.c_uint64
|
||||||
|
|
||||||
|
|
||||||
class XGBoostError(Exception):
|
class XGBoostError(ValueError):
|
||||||
"""Error thrown by xgboost trainer."""
|
"""Error thrown by xgboost trainer."""
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -537,16 +537,13 @@ class XGBModel(XGBModelBase):
|
|||||||
else:
|
else:
|
||||||
params.update({'eval_metric': eval_metric})
|
params.update({'eval_metric': eval_metric})
|
||||||
|
|
||||||
try:
|
self._Booster = train(params, train_dmatrix,
|
||||||
self._Booster = train(params, train_dmatrix,
|
self.get_num_boosting_rounds(), evals=evals,
|
||||||
self.get_num_boosting_rounds(), evals=evals,
|
early_stopping_rounds=early_stopping_rounds,
|
||||||
early_stopping_rounds=early_stopping_rounds,
|
evals_result=evals_result,
|
||||||
evals_result=evals_result,
|
obj=obj, feval=feval,
|
||||||
obj=obj, feval=feval,
|
verbose_eval=verbose, xgb_model=xgb_model,
|
||||||
verbose_eval=verbose, xgb_model=xgb_model,
|
callbacks=callbacks)
|
||||||
callbacks=callbacks)
|
|
||||||
except XGBoostError as e:
|
|
||||||
raise ValueError(e)
|
|
||||||
|
|
||||||
if evals_result:
|
if evals_result:
|
||||||
for val in evals_result.items():
|
for val in evals_result.items():
|
||||||
@ -1230,16 +1227,13 @@ class XGBRanker(XGBModel):
|
|||||||
'Custom evaluation metric is not yet supported for XGBRanker.')
|
'Custom evaluation metric is not yet supported for XGBRanker.')
|
||||||
params.update({'eval_metric': eval_metric})
|
params.update({'eval_metric': eval_metric})
|
||||||
|
|
||||||
try:
|
self._Booster = train(params, train_dmatrix,
|
||||||
self._Booster = train(params, train_dmatrix,
|
self.n_estimators,
|
||||||
self.n_estimators,
|
early_stopping_rounds=early_stopping_rounds,
|
||||||
early_stopping_rounds=early_stopping_rounds,
|
evals=evals,
|
||||||
evals=evals,
|
evals_result=evals_result, feval=feval,
|
||||||
evals_result=evals_result, feval=feval,
|
verbose_eval=verbose, xgb_model=xgb_model,
|
||||||
verbose_eval=verbose, xgb_model=xgb_model,
|
callbacks=callbacks)
|
||||||
callbacks=callbacks)
|
|
||||||
except XGBoostError as e:
|
|
||||||
raise ValueError(e)
|
|
||||||
|
|
||||||
self.objective = params["objective"]
|
self.objective = params["objective"]
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user