Practical Implementation in Scikit-learn
from sklearn.svm import SVC
model = SVC(kernel='rbf', C=1, gamma='scale')
Train the model:
model.fit(X_train, y_train)
Make predictions and evaluate:
y_pred = model.predict(X_test)
from sklearn.metrics import classification_report
print(classification_report(y_test, y_pred))
Grid Search for Hyperparameter Tuning
from sklearn.model_selection import GridSearchCV
param_grid = {'C': [0.1, 1, 10],
'gamma': [1, 0.1, 0.01], 'kernel': ['rbf']}
grid = GridSearchCV(SVC(), param_grid, refit=True, verbose=2)
grid.fit(X_train, y_train)
- Best parameters:
grid.best_params_
- Best estimator:
grid.best_estimator_