使用 SVM 进行时间序列预测?

数据挖掘 Python 预测建模 时间序列 支持向量机
2021-10-02 02:13:48

我有一个这样的熊猫数据框:

(index) 0           sie

0       1997-01-01  11.2
1        1997-01-03  12.3
2        1997-01-04  11.5
...
12454    2017-02-01  13.2

我想使用 SVM 来预测sie. 如何实现 python 代码来预测这些值?

我正在做这样的事情:

model = svm.SVR().fit(df[0],df['sie'])

但它给了我这个错误:

ValueError: Found input variables with inconsistent numbers of samples: [1, 12455]

虽然两者都df[0]具有df['sie']相同的形状(12455,)

注意我没有连续数据(其中的某些日期丢失),其中的值0也是datetime.date()对象。

2个回答

在这里,一篇很好的文章: http: //machinelearningmastery.com/time-series-forecasting-supervised-learning/

简而言之,定义一个大小为 n 的窗口,这就是特征向量的大小。重塑数据集并播放。

我用来解决值错误: model = svm.SVR().fit(np.transpose(np.matrix(df['Dates'])),np.transpose(np.matrix(df['sie'])))

更多信息:https ://stackoverflow.com/questions/30813044/sklearn-found-arrays-with-inconsistent-numbers-of-samples-when-calling-linearre