4

I am facing a trouble when I use lightgbm to conduct grid search.

lgb_classifer = lgb.LGBMRegressor(random_state=12)

grid_lgb = {
    'learning_rate': [0.01,0.05],
    'num_iterations': [5,10,20]}

gbm_lgb = GridSearchCV(estimator =lgb_classifer, param_grid =grid_lgb, scoring = 'recall', cv=3)

---> gbm_lgb.fit(X_train, y_train)

ValueError: Classification metrics can't handle a mix of binary and continuous targets

Both X_train AND y_train is array.y_train is binary label.

Mischa Lisovyi
  • 3,207
  • 18
  • 29
Rya
  • 329
  • 2
  • 15
  • What are types of features in the dataset? – Mischa Lisovyi Jun 22 '18 at 15:08
  • Possible duplicate of [Accuracy Score : ValueError: Can't Handle mix of binary and continuous](https://stackoverflow.com/questions/38015181/accuracy-score-valueerror-cant-handle-mix-of-binary-and-continuous) – Mischa Lisovyi Jun 22 '18 at 15:15
  • @MykhailoLisovyi it didn't have an error when I run any other models like LR,DT,and RF. – Rya Jun 22 '18 at 15:44
  • @MykhailoLisovyi features includes numerical and categorical data(do one hot). – Rya Jun 22 '18 at 15:46

1 Answers1

2

Ah, i needed a second look. But if it not a duplicate of the issue linked in comments, then the problem can be that you define and train a regression model (lgb.LGBMRegressor), while your variable names as well as the chosen metric suggest a classification problem. Try to change the model to lgb.LGBMClassifier

Mischa Lisovyi
  • 3,207
  • 18
  • 29