aiacademy: 機器學習 - 實作: ch08 (practical concers)
Model Parameters Selection
Grid Search Cross Validation
-
Gride Search for SVM Parameters
from sklearn.model_selection import GridSearchCV parameters= {'kernel':['linear', 'rbf'], 'C':[0.01,0.1,1,10], 'gamma':[0.01,0.1,1,10]} model = svm.SVC() model.fit(X, y) best_model = GridSearchCV(model, parameters, cv=5, scoring='accuracy', return_train_score='cv_results_') best_model.fit(X, y)