如何使用libsvm使用5倍交叉验证来估算成本和gamma

时间:2015-07-09 10:24:40

标签: matlab

data = L_f(org,:); % input data to the SVR model  
label =dmos(org); % output of the SVR model   

% the (cost, gamma) parameters for the SVR learning
% the optimal parameters we found for the 3 proposed models on the   
% databases.
% (cost, gamma)  = (65536, 2) for LIVE M1  
% (cost, gamma)  = (1024,   8) for LIVE M2  
% (cost, gamma)  = (16384, 2) for LIVE M3  
% (cost, gamma)  = (32768, 4) for CSIQ M1      
% (cost, gamma)  = (65536, 2) for CSIQ M2  
% (cost, gamma)  = (16384, 2) for CSIQ M3
% (cost, gamma)  = (2048 ,16) for TID2008 M1  
% (cost, gamma)  = (2048,   8) for TID2008 M2  
% (cost, gamma)  = (128,   16) for TID2008 M3  
cost =0.0313 ;
gamma = 3.0518e-05;  
c_str = sprintf('%f',cost);  
g_str = sprintf('%.2f',gamma);     
libsvm_options = ['-s 3 -t 2 -g ',g_str,' -c ',c_str];

spear_results = zeros(N,1);  
% Training and Test procedure  
for i = 1:N  
    % get the index of the distorted image from the index of the reference  
    % image for the traning set and the test set. 
  train = ismember(ref_ind_live,C(i,:)); 
 test = ~train;  

 model = svmtrain(label(train),data(train,:),libsvm_options);  
   [predict_score, ~, ~] = svmpredict(label(test), data(test,:), model);      
   spear_results(i) = corr(predict_score, label(test),'type','Spearman');
 end  
 % median Spearman Coefficient (SRC) performance 
 spear_median = median(spear_results);  
spear_std = std(spear_results,0);   

我正在编写一个评估图像质量的程序。在之前的文章中,作者使用了Libsvm。正如您在此代码中看到的那样,他们分别通过 5倍交叉验证计算成本 gamma ,但我真的不知道他们是怎么做到的。 请帮帮我。

0 个答案:

没有答案