我将GridSearchCV的参数设置为:
parameters = {'kernel':['rbf'], 'C':[1, 5, 0.5], 'gamma':[1, 5, 0.5]}
grid = GridSearchCV(SVC(), parameters)
grid.fit(dataset, targets)
则CCD_ 1或CCD_。如果我更改参数的顺序,并将5放在"C"列表的顶部,则最佳参数为"C"=5和"gamma"=1。
我做错了什么?
您必须将评分参数更改为(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()))