我有40,000个资产的时间序列。我已将数据分为训练数据和目标数据。培训数据有119天的回报,目标数据有59天。我故意将它分解成这种方式。Python; SciKit学习; SVM;形状不匹配
火车:(119行的回报,40000不同系列) 目标:(59行返回的,相同的40000系列)
我跑以下代码以适应模型:
SVR_model = svm.SVR(kernel='rbf',C=100,gamma=.001).fit(t_train_scale.transpose(), t_test.transpose())
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-185-2a0fd827e2a4> in <module>()
1
2
----> 3 SVR_model = svm.SVR(kernel='rbf',C=100,gamma=.001).fit(t_train_scale.transpose(), t_test.transpose())
C:\Users\nnayyar\Anaconda\lib\site-packages\sklearn\svm\base.pyc in fit(self, X, y, sample_weight)
174
175 seed = rnd.randint(np.iinfo('i').max)
--> 176 fit(X, y, sample_weight, solver_type, kernel, random_seed=seed)
177 # see comment on the other call to np.iinfo in this file
178
C:\Users\nnayyar\Anaconda\lib\site-packages\sklearn\svm\base.pyc in _dense_fit(self, X, y, sample_weight, solver_type, kernel, random_seed)
229 cache_size=self.cache_size, coef0=self.coef0,
230 gamma=self._gamma, epsilon=self.epsilon,
--> 231 max_iter=self.max_iter, random_seed=random_seed)
232
233 self._warn_from_fit_status()
C:\Users\nnayyar\Anaconda\lib\site-packages\sklearn\svm\libsvm.pyd in sklearn.svm.libsvm.fit (sklearn\svm\libsvm.c:1864)()
ValueError: Buffer has wrong number of dimensions (expected 1, got 2)
从研究中,我发现使用SVM最常见的答案是形状必须“匹配”,但如何使SVM适合各种大小的数据?
编辑:仍然需要一些帮助,我如何预测成千上万的预测,而不仅仅是下一个1?
你的培训意味着什么119天的回报和目标有59天的回报? – WoodChopper
我在训练集中有119天的回报信息,在目标集中有59天的回报。所以库存1万4千;第1天返回X,第2天返回Y ....有道理? – user2977664