Reputation: 800
I am dealing with a Regression problem for which I used LGBMRegressor
. I also utilize early_stopping
as callback in .fit(...)
as follows:
reg = LGBMRegressor(**lgbr_params)
reg.fit(train_valid[features],
train_valid[target],
verbose=100,
eval_set=[(test[features], test[target])],
eval_metric=['rmse', 'mae'],
callbacks=[early_stopping(stopping_rounds=10, first_metric_only=False)], )
which works quite fine. However, I would like to consider some sort of "tolerance" in my early_stopping
callback function. According to lightgbm documentation, this is apparently possible using min_delta
argument in early stopping callback function.
When I add this to my code:
reg = LGBMRegressor(**lgbr_params)
reg.fit(train_valid[features],
train_valid[target],
verbose=100,
eval_set=[(test[features], test[target])],
eval_metric=['rmse', 'mae'],
callbacks=[early_stopping(stopping_rounds=10, first_metric_only=False), min_delta=[0.1, 0.1]])
I face with the following error:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-39-834c9eaac9b2> in <module>
1 reg = LGBMRegressor(**lgbr_params)
2 reg.fit(train_valid[features], train_valid[target], eval_set=[(test[features], test[target])], eval_metric=['rmse'],
----> 3 callbacks=[early_stopping(stopping_rounds=10, first_metric_only=False, min_delta=[1.0])], verbose=100)
TypeError: early_stopping() got an unexpected keyword argument 'min_delta'
I am using windows, and tried to upgrade the lightbm to solve the issue, but failed. Any idea?
Upvotes: 4
Views: 7443
Reputation: 6667
I was facing the same issue, as latest lightgbm release on pipy is 3.3.1, I had to install it from github.
First install cmake
Install lightgbm from github
git clone --recursive https://github.com/microsoft/LightGBM
cd LightGBM/python-package
python setup.py install
it shoud work now
from lightgbm import early_stopping
early_stopping(stopping_rounds=10, first_metric_only=False, min_delta=[0.1, 0.1])
>>> <function lightgbm.callback.early_stopping.<locals>._callback(env: lightgbm.callback.CallbackEnv) -> None>
Upvotes: 4