如何解决通过SVR和网格搜索使用提前停止
我正在尝试将网格搜索与我的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,'epsilon': [0.001,100]
}
#searchcv.fit(X,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_)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。