I am using grid search for getting the best fit
k=['rbf', 'linear','poly','sigmoid']
c= [1,5,10,20,30,50,80,100]
g=[1e-7,1e-6,1e-5,1e-4,1e-2,0.0001]
param_grid=dict(kernel=k, C=c, gamma=g)
print (param_grid)
grid = GridSearchCV(SVC, param_grid,scoring='accuracy')
grid.fit(X_t_train, y_t_train)
print()
print("Grid scores on development set:")
print()
print (grid.grid_scores_)
print("Best parameters set found on development set:")
print()
print(grid.best_params_)
print("Grid best score:")
print()
print (grid.best_score_)
I am getting a TypeError: get_params() missing 1 required positional argument: 'self' in grid.fit()
This error appears because estimator must be initialied with object and not a class. You need to do either this:
grid = GridSearchCV(SVC(), param_grid, scoring='accuracy')
Or something like this:
clf = SVC()
grid = GridSearchCV(clf, param_grid, scoring='accuracy')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With