SVM and GridSearch

from sklearn.svm import SVC
from sklearn.model_selection import GridSearchCV

param_C = np.logspace(-6, 3, 5)
parameters = [{‘kernel’: [‘rbf’], ‘C’: param_C},
{‘kernel’: [‘poly’], ‘C’: param_C, ‘degree’: [2,3,4]}]

clf_svc = SVC(random_state = 7)

clf_GSCV = GridSearchCV(estimator = clf_svc, param_grid = parameters, cv = 5, n_jobs = -1)

clf_GSCV.fit(X_train.values, y_train.values.flatten())

Been trying this code of using GridSearch on SVM to find optimal values for hyperparameters like C and explore score functions. However keep getting stalled on jupyter notebook on clf_GSCV.fit(X_train.values, y_train.values.flatten())

It is freezing. Any suggestions?

This is the dataset being used Smartphone-Based Recognition of Human Activities and Postural Transitions - UCI Machine Learning Repository

A grid search over that dataset, using SVM, is a huge computational load.

SVM is very computationally intensive, that’s one reason why is is very rarely used.

How long did you wait before deciding it was frozen? Maybe it’s still busy.

ah okay thank you- not very long maybe 10 minutes..

Unfortunately there’s no way to predict now long the process could take. My guess is that 10 minutes is way too short.

A search online suggests that you can add the parameter “verbose = True” when you create the SVC(…) object , and get progress updates during training.

I do not know for sure if this will work, I have not tried it myself.

1 Like

Please use verbose=2 when creating GridSearchCV for observing the overall progress.

1 Like