[python-package] LGBMRegressor.fit() got an unexpected keyword argument 'verbosity'
Description
Am using lightgbm to train regressor model but am getting LGBMRegressor.fit() got an unexpected keyword argument 'verbosity' error.
Reproducible example
#Initialize the model model = lgb.LGBMRegressor(**kwargs, random_state=SEED)
kf = KFold(n_splits=5,shuffle=True,random_state=SEED)
X, y = df.loc[:,features], df.loc[:,target]
d = {}
for k, (train_idx, valid_idx) in enumerate(kf.split(X,y)):
X_train, X_valid, y_train, y_valid = X.loc[train_idx,:], X.loc[valid_idx,:],\
y.loc[train_idx], y.loc[valid_idx]
print(f"Fold {k+1}:")
print("="*7)
model.fit(
X_train, y_train,
eval_set=[(X_train,y_train),(X_valid,y_valid)],
feature_name=features,
categorical_feature=cat_features,
eval_metric='mae',
verbosity=1,
early_stopping_rounds=200
)
Environment info
LightGBM version or commit hash:
Command(s) you used to install LightGBM
Additional Comments
Thanks for using LightGBM!
Parameters like verbosity and early_stopping_rounds need to be passed into the constructor of the scikit-learn estimators in the Python package, not to the fit() method.
import lightgbm as lgb
from sklearn.datasets import make_regression
X, y = make_regression(n_samples=1_000)
reg = lgb.LGBMRegressor(
verbosity=1
)
reg.fit(X, y)
You can find documentation on these methods' signatures at https://lightgbm.readthedocs.io/en/stable/pythonapi/lightgbm.LGBMRegressor.html#lightgbm.LGBMRegressor.fit.
In the future when asking for help here, please do provide the information requested, including:
- the version of LightGBM you're using
- a minimal, reproducible example demonstrating the issue or an explanation of why you aren't able to provide one
- your provided code isn't reproducible... it's missing import statements, you haven't mentioned the versions of LightGBM and Python, and haven't shown how you defined variables like
dfandX
- your provided code isn't reproducible... it's missing import statements, you haven't mentioned the versions of LightGBM and Python, and haven't shown how you defined variables like
Without that type of information, you're asking people here to guess about such details, increasing the effort required to help you.
This issue has been automatically closed because it has been awaiting a response for too long. When you have time to to work with the maintainers to resolve this issue, please post a new comment and it will be re-opened. If the issue has been locked for editing by the time you return to it, please open a new issue and reference this one. Thank you for taking the time to improve LightGBM!
This issue has been automatically locked since there has not been any recent activity since it was closed. To start a new related discussion, open a new issue at https://github.com/microsoft/LightGBM/issues including a reference to this.