clf = svm.SVC(kernel="rbf" , C = 1 , gamma = 1, probability = True)
from sklearn.grid_search import GridSearchCV
gamma_range = [1e-2,1e-1,1e0,1e1,1e2]
c_range = [1e-2,1e-1,1e0,1e1,1e2]
param_grid = dict(gamma = gamma_range, c = c_range)
print param_grid
给出:
{'c': [0.01, 0.1, 1.0, 10.0, 100.0], 'gamma': [0.01, 0.1, 1.0, 10.0, 100.0]}
正如所料,但是当我运行下一段代码时:
grid = GridSearchCV(clf, param_grid, cv= 10, scoring="accuracy")
grid.fit(X_norm, y)
我明白了:ValueError:估算器SVC的参数c无效
我非常确定这些是c的有效值,因为我已经通过自己手动运行它们,我只想微调一切。