sklearn使用小记GridSearchCV

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_)

转载于:https://www.cnblogs.com/erbaodabao0611/p/9843196.html

你可能感兴趣的:(人工智能,数据结构与算法)