1 2 3 4 5 6 7 8 9 10 11 12 13 14
| from sklearn.model_selection import train_test_split from sklearn.svm import SVC from sklearn.model_selection import GridSearchCV
param_grid = {'C': [0.1, 1, 10, 100, 1000], 'gamma': [1, 0.1, 0.01, 0.001, 0.0001]} grid = GridSearchCV(SVC(), param_grid, verbose=3)
grid.fit(X_train, y_train) grid.best_params_ grid.best_estimator_ grid_pred = grid.predict(X_test)
print(classification_report(y_test, grid_pred)) print(confusion_matrix(y_test, grid_pred))
|