Skip to content
Advertisement

`sklearn` asking for eval dataset when there is one

I am working on Stacking Regressor from sklearn and I used lightgbm to train my model. My lightgbm model has an early stopping option and I have used eval dataset and metric for this.

When it feeds into the StackingRegressor, I saw this error

ValueError: For early stopping, at least one dataset and eval metric is required for evaluation

Which is frustrating because I do have them in my code. I wonder what is happening? Here’s my code.

JavaScript

Advertisement

Answer

I guess the issue is causing by the fact that early_stopping was used in the LGBMRegressor, thus it expects eval data in StackingRegressor() as well.

Try doing the following:

Just after the line you’ve fitted your LGBMRegressor() model with the following line – m1.fit(X_train_df, y_train_df, eval_set = (X_val_df, y_val_df), eval_metric = 'rmse'), add these lines after that.

JavaScript

see if the error goes away.

Advertisement