Gridsearchcv & Randomsearchcv

Hi Everyone, i am trying to run a hyper parameter tuning for my model but i keep getting this

defining parameter range
param_grid = {‘C’: [0.1, 1, 10, 100, 1000],
‘gamma’: [1, 0.1, 0.01, 0.001, 0.0001],
‘kernel’: [‘rbf’]}
grid = GridSearchCV(SVC(), param_grid, refit = True, verbose = 3)
fitting the model for grid search
grid.fit(X_train, y_train)
clf = svm.SVC(C = 10, gamma = 1)
clf.fit(X_train,y_train)

Error! Session/line number was not unique in database. History logging moved to new session 553

what can be the issue?

Hi OlutokiJohn

Did you solve the issue or are you still looking for a solution for this.
I did run your code with a dummy dataset and it works fine

from sklearn.svm import SVC
from sklearn.model_selection import GridSearchCV

# defining parameter range
param_grid = {'C': [0.1, 1, 10, 100, 1000],
              'gamma': [1, 0.1, 0.01, 0.001, 0.0001],
              'kernel': ['rbf']}
grid = GridSearchCV(SVC(), param_grid, refit=True, verbose=3)
# fitting the model for grid search
grid.fit(X_train, y_train)
clf = svm.SVC(C = 10, gamma = 1)
clf.fit(X_train,y_train)

And got the output as follows:

Fitting 5 folds for each of 25 candidates, totalling 125 fits
[CV 1/5] END ........C=0.1, gamma=1, kernel=rbf;, score=0.637 total time=   0.0s
[CV 2/5] END ........C=0.1, gamma=1, kernel=rbf;, score=0.637 total time=   0.0s
[CV 3/5] END ........C=0.1, gamma=1, kernel=rbf;, score=0.625 total time=   0.0s
[CV 4/5] END ........C=0.1, gamma=1, kernel=rbf;, score=0.633 total time=   0.0s
[CV 5/5] END ........C=0.1, gamma=1, kernel=rbf;, score=0.633 total time=   0.0s
[CV 1/5] END ......C=0.1, gamma=0.1, kernel=rbf;, score=0.637 total time=   0.0s
[CV 2/5] END ......C=0.1, gamma=0.1, kernel=rbf;, score=0.637 total time=   0.0s
[CV 3/5] END ......C=0.1, gamma=0.1, kernel=rbf;, score=0.625 total time=   0.0s
[CV 4/5] END ......C=0.1, gamma=0.1, kernel=rbf;, score=0.633 total time=   0.0s
...

So I guess it could be an issue with data or session.

2 Likes

yes it was the data that caused it, it’s quite large

1 Like