# svm回归matlab工具箱很慢,Matlab的svm回归效果不好请大家帮我看看程序那错了

[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

• 0
点赞
• 0
收藏
• 0
评论
06-17 2261
03-07 2611
05-06 7894
11-06 3万+
05-04 2195
10-24 4630
06-07 9177
04-12 3万+
03-06 7372
10-30 2392
03-08 2945
09-25 937

### “相关推荐”对你有帮助么？

• 非常没帮助
• 没帮助
• 一般
• 有帮助
• 非常有帮助

1.余额是钱包充值的虚拟货币，按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载，可以购买VIP、C币套餐、付费专栏及课程。