how to tune parameters of custom kernel function with pipeline in scikit-learn

▼魔方 西西 提交于 2019-11-29 03:39:55

Wrap the model using a function:

def GBC(self):
        model = GradientBoostingRegressor()
        p = [{'learning_rate':[[0.0005,0.01,0.02,0.03]],'n_estimators':[[for i in range(1,100)]],'max_depth':[[4]]}]
        return model,p

Then test it with a kernel by Parameter Grid:

def kernel(self,model,p):
        parameter = ParameterGrid(p)
        clf = GridSearchCV(model, parameter, cv=5, scoring='neg_mean_squared_error',n_jobs=2)
        clf.fit(X,Y)

Use this approach you can manage the kind of function and its set of hyperparameters over a distinct function, call the function directly in main

a = the_class()
a.kernel(a.GBC())

Attacking the problem from a slightly different angle - how about using an automated parameter tuning with auto-sklearn? It is a drop-in replacement of sklearn and frequently it does a better job than manually tuned parameters.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!