def First_Model_SVR(Scaled_Input_Data, Output_Data):
T0 = time.time()
n = len(Scaled_Input_Data)
Grid_Dict = {"C": [1e-2, 1e-1,1e0, 1e1, 1e2],"gamma": np.logspace(-4, 2, 6)}
svr_Tuned = GridSearchCV(SVR(kernel='rbf', gamma=0.1, tol = 0.005), cv=5,param_grid=Grid_Dict, scoring="mean_absolute_error")
svr_Tuned.fit(Scaled_Input_Data, Output_Data)
SVR_MSE = SVR(kernel='rbf', C=svr_Tuned.best_params_['C'], gamma=svr_Tuned.best_params_['gamma'], tol = 0.01)
SVR_Time = time.time() - T0
print('The computational time of Radial based Support Vector Regression for ', n, ' examples is: ', SVR_Time)
MSEs_SVR = cross_validation.cross_val_score(SVR_MSE, Scaled_Input_Data, Output_Data, cv=cross_validation.LeaveOneOut(n), scoring="mean_absolute_error")
MeanMSE_SVR = np.mean(list(MSEs_SVR))
print('The average MSE of Radial based Support Vector Regression for ', n, ' examples is: ', (-1*MeanMSE_SVR))
return(MeanMSE_SVR, svr_Tuned)
Models.py 文件源码
python
阅读 24
收藏 0
点赞 0
评论 0
评论列表
文章目录