【发布时间】:2021-02-26 14:57:34
【问题描述】:
我有以下管道:
from sklearn.pipeline import Pipeline
import lightgbm as lgb
steps_lgb = [('lgb', lgb.LGBMClassifier())]
# Create the pipeline: composed of preprocessing steps and estimators
pipe = Pipeline(steps_lgb)
现在我想使用以下命令设置分类器的参数:
best_params = {'boosting_type': 'dart',
'colsample_bytree': 0.7332216010898506,
'feature_fraction': 0.922329814019706,
'learning_rate': 0.046566283755421566,
'max_depth': 7,
'metric': 'auc',
'min_data_in_leaf': 210,
'num_leaves': 61,
'objective': 'binary',
'reg_lambda': 0.5185517505019249,
'subsample': 0.5026815575448366}
pipe.set_params(**best_params)
然而这会引发错误:
ValueError: Invalid parameter boosting_type for estimator Pipeline(steps=[('estimator', LGBMClassifier())]). Check the list of available parameters with `estimator.get_params().keys()`.
boosting_type 绝对是 lightgbm 框架的核心参数,但是如果(从 best_params 中删除)其他参数会导致 valueError 被提升。
所以,我想要的是在创建管道后设置分类器的参数。
【问题讨论】:
标签: scikit-learn pipeline lightgbm