less than 1 minute read

Tags: , ,

github-aiacademy

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)