Using early stopping with SVR and grid search

865 views Asked by At

I am trying to use a grid search with my SVR model, and as it takes too much time to fit I wonder if I could use the early stopping, but I don't know how to do so. Instead, I used max_iter, but still not sure of my best parameters. Any suggestion? Thank you!

#We can use a grid search to find the best parameters for this model. Lets try
#X_feat = F_DF.drop(columns=feat)
y = F_DF["Production_MW"]
X_train, X_test, y_train, y_test = train_test_split(X, y,test_size=0.2, random_state=42)
#Define a list of parameters for the models
params = {'C': [0.001, 0.01, 0.1, 1, 10, 100],
            'gamma': [0.001, 0.01, 0.1, 1, 10, 100],
          'epsilon': [0.001, 0.01, 0.1,  1,  10, 100]
         }

#searchcv.fit(X, y, callback=on_step)
#We can build Grid Search model using the above parameters. 
#cv=5 means cross validation with 5 folds
grid_search = GridSearchCV(SVR(kernel='rbf'), params, cv=5, n_jobs=-1,verbose=1)
grid_search.fit(X_train, y_train)

print("train score - " + str(grid_search.score(X_train, y_train)))
print("test score - " + str(grid_search.score(X_test, y_test)))

print("SVR GridSearch score: "+str(grid_search.best_score_))
print("SVR GridSearch params: ")
print(grid_search.best_params_)
0

There are 0 answers