7

As you can see, I have a problem with using sklearn (lightgbm, GridSearchCV). Please let me know how to solve this error.

My code is the following:

import lightgbm as lgb
from lightgbm.sklearn import LGBMClassifier

estimator = lgb.LGBMClassifier()
param_grid = {
    'num_leaves': [15, 30, 60],
    'min_data_in_leaf': [18, 36, 72],
    'learning_rate': [0.05, 0.1, 0.2],
    'n_estimators': [4, 8, 16]
}

from sklearn.model_selection import GridSearchCV
grid = GridSearchCV(estimator, param_grid, cv=5)
lgb_grid = grid.fit(X_train, y_train)

And it raises this error:

/usr/local/lib/python3.6/dist-packages/sklearn/model_selection/_validation.py:536: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: 
ValueError: bad input shape (33120, 4)

  FitFailedWarning)
Tonechas
  • 13,398
  • 16
  • 46
  • 80
E.Kim
  • 95
  • 1
  • 2
  • 2
    Please note: the error is clearly telling you that there is something wrong with your input, but you are not providing your input to us – Federico Dorato Apr 27 '20 at 04:41
  • Have you found the answer? I am having similar issue. – vasili111 May 16 '20 at 00:31
  • Does this answer your question? [sklearn classifier get ValueError: bad input shape](https://stackoverflow.com/questions/31306390/sklearn-classifier-get-valueerror-bad-input-shape) – Qusai Alothman Dec 05 '20 at 06:11

0 Answers0