def test_grid_search(): from sklearn import datasets,svm iris = datasets.load_iris() parameters = {'kernel': ('linear', 'rbf'), 'C': [1, 10,50,100]} #注意score='roc_auc'是二分類的,多分類會報錯 svc = svm.SVC() clf = GridSearchCV(svc, parameters,cv=7) clf.fit(iris.data, iris.target) print(type(clf.best_params_)) print(clf.best_params_)