首页 > 编程知识 正文

支持向量机回归预测,支持向量机算法用matlab实现

时间:2023-05-05 04:50:09 阅读:10482 作者:3432

最近开始学习了,支持向量机最终能回归吗? 是否能取得好的效果,我真的很困惑。 至少在libsvm中没有取得好的效果。 但是,像在空中飞舞一样有很好效果的文献是假的吗? 我很困惑。 期待tsdjd的指导,试着把我自己做的结果发送到这里。 通过结构的函数模型进行验证。

clear clc;

%一元函数的回归和预测,没关系

x1=(-1:0.1:1 ) );

y=-x1.^2; plot(x1,y,' ro ' ); 保持接通;

模型=SVM train (y,x1,'-s 3 -t 2 -c 2.2 -g 2.8 -p 0.01 );

[py,MSE]=SVMpredict(y,x1,model );

plot(x1、py、' b* ); testx=[1.1 1.2 1.3] '; testy=-testx.^2;

%testx=[-0.55 -0.65 -0.75] '; testy=-testx.^2; 取值在区间内有效。 这是我自己做的。

[pyt,MSE]=SVMpredict(testy,testx,model ); %这是一个视频示例

clear clc;

%一元函数的回归和预测、参数的优秀再预测非常有效

x1=(-1:0.1:1 ) );

y=-x1.^2;

plot(x1,y,' ro ' ); 保持接通;

[bestmse,bestc,bestg]=svmcgforregress(y,x1,-10,-20,- 10,10 );

cmd=['-s 3 -t 2 '、'-c '、num2str(bestc )、'-g )、num2str(bestc ) ]

模型=SVM train (y,x1,cmd );

[py,MSE]=SVMpredict(y,x1,model );

plot(x1、py、' b* ); testx=[1.1 1.2 1.3] '; testy=-testx.^2.sin(testx );

[pyt,MSE]=SVMpredict(testy,testx,model );

clear clc;

%可以回归和预测一元函数,优化和预测参数,实现效果

x1=(-1:0.1:1 ) );

y=-x1.^23*sin(x1 );

plot(x1,y,' ro ' ); 保持接通;

[bestmse,bestc,bestg]=svmcgforregress(y,x1,-10,-20,- 10,5 );

%cmd=['-s 3 -t 2 '、'-c '、num2str(bestc )、'-g )、num2str(bestc ) ]

模型=SVM train (y,x1,'-s 3 -t 2 -c8 -g 0.5 -p 0.01 );

[py,MSE]=SVMpredict(y,x1,model );

plot(x1、py、' b* ); testx=[1.1 1.2 1.3] '; testy=-testx.^2.3*sin(testx );

%二元函数的回归和预测效果非常差

x1=(-1:0.1:1 ) ); x2=(0:0.1:2 ); x=[x1 x2];

y=-x1.^3sin(x2 );

[bestmse,bestc,bestg]=svmcgforregress(y,x,-10,-30,- 10,10,3,0.5,0.5 );

cmd=['-s 3 -t 2 '、'-c '、num2str(bestc )、'-g )、num2str(bestc ) ]

模型=SVM train (y,x,cmd );

[py,MSE]=SVMpredict(y,x,model );

testx1=[1.1 1.2 1.3] '; testx2=[2 2.1 2.2] '; testy=-testx1.^3sin(testx2 );

[pyt,MSE]=SVMpredict(testy,[testx1,testx2],model );

p=() (pyt-testy )./testy ) ';

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。