Skip to content Skip to sidebar Skip to footer

Invalid Parameter Loss For Estimator Svr

This is my code i used grid search cv for hyper parameter tuning. but it shows error. param_grid = {'kernel' : ['linear', 'poly', 'rbf', 'sigmoid'], 'loss' : ['epsilon_

Solution 1:

Some errors that I spotted:

  • You seem to be specifying a loss parameter and possible values, that are only defined for a LinearSVR, not a SVR. On another hand, if you do want to use a LinearSVR, you can't specify a kernel, since it has to be linear.

  • I also noticed that 'C' : [np.arange(0,20,1)] in the definition of the grid will yield an error, since it results in a nested list. Just use np.arange(0,20,1)

Assuming then you have a SVR, the following should work for you:

from sklearn.svm importSVRsvr= SVR()

param_grid = {"kernel" : ['linear', 'poly', 'rbf', 'sigmoid'],
             "max_iter" : [1,10,20],
             'C' : np.arange(0,20,1)} 

model = GridSearchCV(estimator = svr, param_grid = param_grid, 
                     cv = 5, verbose = 3, n_jobs = -1)
m1 = model.fit(X_train, y_train)

Post a Comment for "Invalid Parameter Loss For Estimator Svr"