Why do parameters in output of my support vector regression are going to zero?
1 view (last 30 days)
Show older comments
I am trying to predict next value in a time series from epsilon-support vector regression using libsvm library in matlab.Following is my code. From an excel file, I am taking first 3500 samples for training. Based on minimum cross validation mean square error, I want to decide how many lags to consider in order to predict the next value.
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;
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.
end
but on executing this code, for all iterations and for all values of d, I get the following output on console
optimization finished, #iter = 0
nu = 0.000000
obj = 0.000000, rho = -49.125125
nSV = 0, nBSV = 0
i.e the values of iter,nu,obj,nSV and nBSV are always 0. What is wrong with my code. Please help !!!
0 Comments
Answers (0)
See Also
Categories
Find more on Statistics and Machine Learning Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!