24小时热门版块排行榜    

CyRhmU.jpeg
查看: 419  |  回复: 2
当前主题已经存档。

hwwj

铜虫 (小有名气)

[交流] 【求助】svm回归效果不好请大家帮我看看程序那错了

用LIBSVM做的回归,效果很不好,找不到原因,请大家帮忙找找。
下面这个程序是挑选最佳c和g的,帮我找找错误,谢谢了。
     load principal28 ;     %载入数据矩阵PCA28(24*6)
[pn,minp,maxp] = premnmx(PCA28);
indices=crossvalind('kfold',24,24);
y1 =[4.9085;5.2529;4.9370;8.400;6.600;5.900;7.200;9.9494;6.2787;6.3711;7.1139;6.3617;5.4314;4.7160;7.0414;6.8751;8.4472;7.1461;8.477;8.431;7.6628;6.041;6.3824;7.6532];
tt = 2;
Count = 0;
for Gamma = -15 :3
     g = 2.^Gamma;
  Count = Count + 1;
  GG(Count) = Gamma;
  Tim = 0;
  for Penalty = -5 :15
          c = 2.^Penalty;
         Tim = Tim + 1;
         CC(Tim) = Penalty;
          predict = [];
          MSE =[];
          d =[];
         for k = 1 : 24
              test = ( indices24 == k); train = ~test;
              xtest = pn(test,;  xlearn = pn(train, ;
              ytest = y1(test);    ylearn = y1(train);   
              eval(['model = svmtrain(ylearn, xlearn, ''-s 3 ' '-t ' num2str(tt) ' -g ' num2str(g) ' -c ' num2str(c)  '-p 0.1 '');'])
             [predict_label,accuracy]  = svmpredict(ytest, xtest, model,'-b 0 ' );
             d=cat(1,d,ytest);
      predict = cat(1,predict,predict_label);
         end
      h=1:24;
      mse(Count,Tim) = sqrt(sum ((predict(h) -d(h) ).^2)/24);
      MSE =cat(1,MSE,mse);
       r=sqrt((sum((predict-mean(d)).^2))/(sum((d-mean(d)).^2)));
       R2=1-(sum((d-predict).^2)/sum((mean(ytest)-d).^2));
      SE=sqrt((sum((d-predict).^2))/24);
       end
end
[AA, BB] = find( MSE == min(min(MSE )));
  Gamma = GG(AA) ;
  bg =  2.^Gamma;  
  Penalty = CC(BB);
  bc =  2.^Penalty;
  save bestc bc
  save bestg bg
回复此楼
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

hwwj

铜虫 (小有名气)

这个是预测的程序

这个是预测的程序
load principal28 ;
bc=?;%上一程序所得值
bg=?;%上一程序所得值
[pn,minp,maxp] = premnmx(PCA28);
ylearn =[4.9085;5.2529;4.9370;8.400;6.600;5.900;7.200;9.9494;6.2787;6.3711;7.1139;6.3617;5.4314;4.7160;7.0414;6.8751;8.4472;7.1461;8.477;8.431;7.6628;6.041;6.3824;7.6532];
xlearn= [pn(1,:);pn(2,:);pn(3,:);pn(4,:);pn(5,:);pn(6,:);pn(7,:);pn(8,:);pn(9,:);pn(10,:);pn(11,:);pn(12,:);pn(17,:);pn(18,:);pn(19,:);pn(20,:);pn(21,:);pn(22,:);pn(23,:);pn(24,:);pn(25,:);pn(26,:);pn(27,:);pn(28,:);];
Xtest =[pn(13,:);pn(14,:);pn(15,:);pn(16,:)];
Ytest =[6.0792;7.3424;4.8921;5.9345;];
tt = 2;
predict = [];
    eval(['model= svmtrain(ylearn, xlearn, ''-s 3 ' '-t ' num2str(tt) ' -g ' num2str(bg) ' -c ' num2str(bc)  '-p 0.1 -b 0 '');'])
         
        [predict_label,accuracy]  = svmpredict(Ytest, Xtest, model ,'-b 0 ' );
         predict = cat(1,predict,predict_label);

Q=sqrt(1-(sum((Ytest-predict).^2)/sum((Ytest-sum(Ytest)/4).^2)));
SE=sqrt((sum(( Ytest-predict).^2))/24);
2楼2009-09-30 21:03:37
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

xin378

金虫 (正式写手)

我以前用过lsSVM,可惜现在都忘了。。
3楼2009-10-10 13:03:33
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 hwwj 的主题更新
普通表情 高级回复(可上传附件)
信息提示
请填处理意见