application_vnd.jupyter.stderr_output_2.png text_plain_output_3.png text_plain_output_1.png
from sklearn.model_selection import GridSearchCV

from sklearn.model_selection import KFold

from sklearn.svm import SVC

import pandas as pd

df = pd.read_csv('train.csv')

folds = KFold(n_splits=5, shuffle=True, random_state=101)
hyper_params = [{'gamma': [0.01, 0.001, 0.0001], 'C': [1, 10, 100, 1000]}]
model = SVC(kernel='rbf')
model_cv = GridSearchCV(estimator=model, param_grid=hyper_params, scoring='accuracy', cv=folds, verbose=1, return_train_score=True)
model_cv.fit(X_train, y_train)

cv_results = pd.DataFrame(model_cv.cv_results_)
cv_results

best_score = model_cv.best_score_
best_hyperparams = model_cv.best_params_
print('The best test score is {0} corresponding to hyperparameters {1}'.format(best_score, best_hyperparams))