小编Kic*_*icK的帖子

使用管道的 XGBRegressor

我正在将XGBRegressor与 Pipeline 一起使用。管道包含预处理步骤和模型(XGBRegressor)。

以下是完整的预处理步骤。(我已经定义了numeric_colscat_cols

numerical_transfer = SimpleImputer()
cat_transfer = Pipeline(steps = [
   ('imputer', SimpleImputer(strategy = 'most_frequent')),
   ('onehot', OneHotEncoder(handle_unknown = 'ignore'))
   ])
preprocessor = ColumnTransformer(
   transformers = [
   ('num', numerical_transfer, numeric_cols),
   ('cat', cat_transfer, cat_cols)
   ])
Run Code Online (Sandbox Code Playgroud)

最终的管道是

my_model = Pipeline(steps = [('preprocessor', preprocessor), ('model', model)])

当我尝试在不使用Early_stopping_rounds 的情况下进行拟合时,代码工作正常。

(my_model.fit(X_train, y_train))

但是当我使用如下所示的Early_stopping_rounds时,我收到错误。

my_model.fit(X_train, y_train, model__early_stopping_rounds=5, model__eval_metric = "mae", model__eval_set=[(X_valid, y_valid)])

我收到错误:

 model__eval_set=[(X_valid, y_valid)]) and the error is

ValueError: DataFrame.dtypes for data must be …
Run Code Online (Sandbox Code Playgroud)

python pipeline machine-learning xgboost

5
推荐指数
1
解决办法
1052
查看次数

标签 统计

machine-learning ×1

pipeline ×1

python ×1

xgboost ×1