GridSearchCV
来源: https://blog.csdn.net/woaixuexihhh/article/details/84702233
from sklearn.model_selection import GridSearchCV
param_grid = {'svc__C': [1, 5, 10],
'svc__gamma': [0.0001, 0.0005, 0.001]}
grid = GridSearchCV(model, param_grid)
print(Xtrain.shape, ytrain.shape)
grid.fit(Xtrain, ytrain) #建立模型
print(grid.best_params_) #输出模型的参数组合
model = grid.best_estimator_ #输出最好的模型
yfit = model.predict(Xtest)
GridSearchCV最先出现在Python成神之路。
共有 0 条评论