Guest User

Untitled

a guest
Jan 23rd, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. # Perform Grid Search on the SVR model to find the optimal parameters to achieve a lower MSE.
  2. # 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.
  3. from sklearn.svm import SVR
  4. from sklearn.model_selection import GridSearchCV
  5. regressor = SVR(kernel = 'linear')
  6. parameters = [{'C': [1], 'kernel': ['linear']},
  7. {'C': [1, 10, 100, 1000], 'kernel': ['rbf']},
  8. {'C': [1, 10, 100, 1000], 'kernel': ['sigmoid']}]
  9. grid_search = GridSearchCV(estimator = regressor,
  10. param_grid = parameters,
  11. scoring = 'neg_mean_squared_error',
  12. n_jobs = -1)
  13.  
  14. # Fit GridSearchCV to the training dataset.
  15. grid_search = grid_search.fit(X_train, y_train)
Add Comment
Please, Sign In to add comment