October 2018
Intermediate to advanced
172 pages
4h 6m
English
In this section, you will learn how to optimize the inverse regularization strength using the GridSearchCV algorithm. We can do this using the following code:
from sklearn.model_selection import GridSearchCV#Building the model svm = LinearSVC(random_state = 50)#Using GridSearchCV to search for the best parametergrid = GridSearchCV(svm, {'C':[0.00001, 0.0001, 0.001, 0.01, 0.1, 10]})grid.fit(X_train, y_train)# Print out the best parameterprint("The best value of the inverse regularization strength is:", grid.best_params_)
In the preceding code, the following applies:
Read now
Unlock full access