我一直在尝试使用Python语言中的支持向量回归(SVR)工具来实现时间序列预测。我使用scikit-learn中的SVR模块进行非线性支持向量回归。但是,我在预测未来事件方面遇到了严重问题。回归线很好地拟合了原始函数(从已知数据),但是一旦我想要预测未来步骤,它就会返回最后一个已知步骤的值。
我的代码如下:
import numpy as np
from matplotlib import pyplot as plt
from sklearn.svm import SVR
X = np.arange(0,100)
Y = np.sin(X)
svr_rbf = SVR(kernel='rbf', C=1e5, gamma=1e5)
y_rbf = svr_rbf.fit(X[:-10, np.newaxis], Y[:-10]).predict(X[:, np.newaxis])
figure = plt.figure()
tick_plot = figure.add_subplot(1, 1, 1)
tick_plot.plot(X, Y, label='data', color='green', linestyle='-')
tick_plot.axvline(x=X[-10], alpha=0.2, color='gray')
tick_plot.plot(X, y_rbf, label='data', color='blue', linestyle='--')
plt.show()
有什么想法吗?
提前感谢,
汤姆