我将GridSearchCV的参数设置为:
parameters = {'kernel':['rbf'], 'C':[1, 5, 0.5], 'gamma':[1, 5, 0.5]}
grid = GridSearchCV(SVC(), parameters)
grid.fit(dataset, targets)
然后grid.best_params_
或grid.best_estimator_
始终将列表中的第一个参数返回为最佳(即1和1)。如果我改变参数的顺序并将5放在列表顶部的'C',那么最好的参数是'C'= 5和'gamma'= 1。
我做错了什么?
答案 0 :(得分:0)
你必须将评分参数更改为(roc_auc),她就是一个例子:
grid = GridSearchCV(model, param_grid = p, scoring='roc_auc')
grid.fit(self.train_data, self.train_labels)
print('\nThe best hyper-parameter for -- {} is {}, the corresponding mean accuracy through 10 Fold test is {} \n'\
.format(name, grid.best_params_, grid.best_score_))
model = grid.best_estimator_
train_pred = model.predict(self.train_data)
print('{} train accuracy = {}\n'.format(name,(train_pred == self.train_labels).mean()))