为什么支持向量回归的输出中的参数变为零?

时间:2015-05-21 10:03:18

标签: svm matlab libsvm

我正在尝试使用matlab中的libsvm库从epsilon支持向量回归的时间序列中预测下一个值。以下是我的代码。从excel文件中,我将首先采集3500个样本进行培训。基于最小交叉验证均方误差,我想决定为了预测下一个值而要考虑多少滞后。

filename='test.xlsx';
F=xlsread(filename,'B2:B5001');
f_trainx =(1:3500)';  % time instants
f_trainy=F(1:3500);  % observed values
f_testx=(3501:5000)';
f_testy=F(3501:5000);

for d=0:20   %% d= no. of lags considered for prediction  
   [C,gamma,eps] = meshgrid(-10:2:15, -20:2:3 , -20:2:3); 
   svm_ip=f_trainx(end:-1:end-d);
   svm_op=f_trainy(end:-1:end-d);
   s=3;  % for epsilon svr
   t=2;  % for rbf kernel
   folds = 5;
   h=0;
   %p=2^5; % value of epsilon

   for j=1:numel(C)
      mse(j) = svmtrain(svm_op,svm_ip, ...          
      sprintf('-s %d -t %d -c %f -g %f -p %f  -v %d -h %d',s,t, 2^C(j), ... 
      2^gamma(j),2^eps(j), folds ,h));
   end

   [~,idx] = min(mse);
   mse_cv =mse(idx);
   best_C = 2^C(idx);
   best_gamma = 2^gamma(idx) ;
   best_eps = 2^eps(idx);
   options = sprintf(' -s %d -t %d -c %f -g %f ...
                                      -p %f -%d',s,t,2^C(idx),2^gamma(idx),2^eps(idx),h);
   model   = svmtrain(svm_op, svm_ip, options)

   x2 = 3501 ; % first value from test set
   y2 = rand(1); % y2 is to be predicted,so taking any random value for it.

但是在执行此代码时,对于所有迭代,我在控制台上获得以下输出

optimization finished, #iter = 0
nu = 0.000000
obj = 0.000000, rho = -49.125125
nSV = 0, nBSV = 0

,iter,nu,obj,nSV和nBSV的值始终为0.我的代码出了什么问题?

0 个答案:

没有答案