【发布时间】:2020-10-24 01:07:21
【问题描述】:
我目前正在研究一个多输出回归问题,我试图一次预测多个输出值。我知道有一些标准回归器本身就支持这项任务。
但是,我想使用 RegressorChain 并使用 GridSearchCV 调整 RegressorChain 中 Regressor 的超参数。为此,我编写了以下代码:
from sklearn.pipeline import Pipeline
from sklearn.preprocessing import StandardScaler
from sklearn.svm import SVR
from sklearn.model_selection import GridSearchCV
# setup the pipeline
pipeline = Pipeline(steps = [('scale', StandardScaler(with_mean=True, with_std=True)),
('estimator', RegressorChain(SVR())])
# setup the parameter grid
param_grid = {'estimator__estimator__C': [0.1,1,10,100]}
# setup the grid search
grid = GridSearchCV(pipeline,
param_grid,
scoring='neg_mean_squared_error')
# fit model
grid.fit(X, y)
试过了:
param_grid = {'estimator__C': [0.1,1,10,100]}
和:
param_grid = {'estimator__estimator__C': [0.1,1,10,100]}
但我两次都得到了以下ValueError:
ValueError:估计器的参数 C 无效 RegressorChain(base_estimator=SVR(C=1.0, cache_size=200, coef0=0.0, 度数=3,ε=0.1,伽玛='auto_deprecated',内核='rbf', max_iter=-1, 收缩=真, tol=0.001, 详细=假), cv=None,order=None,random_state=None)。使用
estimator.get_params().keys()查看可用参数列表。
有人知道如何正确设置此管道吗?谢谢!
【问题讨论】:
标签: python scikit-learn regression gridsearchcv