python - LightGBM-分类指标无法处理二进制和连续目标的混合

标签 python scikit-learn grid-search lightgbm

当我使用 lightgbm 进行网格搜索时,我遇到了麻烦。

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


两者 X_trainy_trainarray . y_train是二进制标签。

最佳答案

啊,我需要再看一眼。但如果它不是评论中链接的问题的重复,那么问题可能在于您定义和训练了 回归 模型 (lgb.LGBMRegressor),而您的变量名称以及所选指标表明存在分类问题。尝试将模型更改为 lgb.LGBMClassifier

关于python - LightGBM-分类指标无法处理二进制和连续目标的混合,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50973373/

相关文章:

python - 在Python中,如何进行字符串替换并检索替换的子字符串?

python - 在 python 中的 imshow 中获取正确的轴标签

python - sklearn 逻辑回归的特点

python - scikit 学习 : desired amount of Best Features (k) not selected

machine-learning - Bagging 分类器的 'max_samples' 关键字如何影响每个基本估计器使用的样本数量?

python - 搜索大tar.gz文件中的关键字,复制并删除

python - 使用 Selenium 在动态表中搜索字符串

python - 值错误 : bad input shape (2835, 18)

python - 使用网格搜索的交叉验证返回比默认更差的结果

python - 如何组合字典不同键的每个值以在 Python 中生成数据框?