1

我正在尝试对我的 SVR 模型使用网格搜索,并且由于需要太多时间来适应我想知道是否可以使用提前停止,但我不知道该怎么做。相反,我使用了 max_iter,但仍然不确定我的最佳参数。有什么建议吗?谢谢!

#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_)
4

0 回答 0