我試圖找到最佳值的C &伽馬SVR()估計使用GridSearchCV(),但我得到這個錯誤RBF SVM參數在scikit中使用GridSearchCV()學習.... TypeError:'KFold'對象不可迭代
類型錯誤: 'KFold' 對象不是可迭代
此代碼
from sklearn.grid_search import GridSearchCV
from sklearn.model_selection import KFold
C_range = np.logspace(-2, 10, 13)
gamma_range = np.logspace(-9, 3, 13)
param_grid = dict(gamma=gamma_range, C=C_range)
cv = KFold(n_splits=5, shuffle=False, random_state=None)
grid = GridSearchCV(SVR(kernel='rbf'), param_grid=param_grid, cv=cv)
grid.fit(X, y)
print("The best parameters are %s with a score of %0.2f"
% (grid.best_params_, grid.best_score_))