Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Perform Grid Search on the SVR model to find the optimal parameters to achieve a lower MSE.
- # The poly kernel was excluded as it never converged to a solution. The same was done for C values 10, 100 and 1000 for the linear kernel.
- from sklearn.svm import SVR
- from sklearn.model_selection import GridSearchCV
- regressor = SVR(kernel = 'linear')
- parameters = [{'C': [1], 'kernel': ['linear']},
- {'C': [1, 10, 100, 1000], 'kernel': ['rbf']},
- {'C': [1, 10, 100, 1000], 'kernel': ['sigmoid']}]
- grid_search = GridSearchCV(estimator = regressor,
- param_grid = parameters,
- scoring = 'neg_mean_squared_error',
- n_jobs = -1)
- # Fit GridSearchCV to the training dataset.
- grid_search = grid_search.fit(X_train, y_train)
Add Comment
Please, Sign In to add comment