支持向量回归-RBF模型

时间:2020-04-19 21:20:10

标签: python regression

当我尝试运行下面的函数时,RBF模型将我的Jupyter笔记本放入循环并阻塞了代码。我的Jupyter笔记本是最新的,我缺少什么吗?

我还返回错误:FutureWarning:在0.22版中,伽玛的默认值将从“自动”更改为“缩放”,以更好地说明未缩放的功能。请将gamma显式设置为“自动”或“缩放”,以避免出现此警告。 “避免此警告。”,FutureWarning)

defpredict_scores(日期,得分,x): date = np.reshape(dates,(len(dates),1))

svr_lin = SVR(kernel= 'linear' , C=1e3)
svr_poly = SVR(kernel = 'poly', C=1e3, degree = 2)
**svr_rbf = SVR(kernel = 'rbf' , C=1e3, gamma = 'auto')**
svr_lin.fit(dates,scores)
svr_poly.fit(dates,scores)
svr_rbf.fit(dates,scores)

plt.scatter(dates, scores, color='black', label='Data')
plt.plot(dates, svr_rbf.predict(dates), color='red', label='RBF Model')
plt.plot(dates, svr_lin.predict(dates), color='green', label='Linear Model')
plt.plot(dates, svr_poly.predict(dates), color='blue', label='Polynomial Model')
plt.xlabel('Date')
plt.ylabel('Score')
plt.title('Support Vector Regression')
plt.legend()
plt.show()

return svr_rbf.predict(x)[0], svr_lin.predict(x)[0], svr_poly.predict(x)[0]

0 个答案:

没有答案