資源簡介
matlab回歸預(yù)測的源代碼,使用RBF和SVM兩種機(jī)器學(xué)習(xí)法,對這兩種方法進(jìn)行了對比。
代碼片段和文件信息
clc;
clear;
close?all;
%產(chǎn)生學(xué)習(xí)數(shù)據(jù)generate?the?learing?data
ld=400;?%???????
x=rand(2ld);?%在0和1之間隨機(jī)產(chǎn)生2*400的行列式
x=(x-0.5)*1.5*2;?%-1.5?1.5?
x1=x(1:);%1*400的行向量
x2=x(2:);%1*400的行向量
F=20+x1.^2-10*cos(2*pi*x1)+x2.^2-10*cos(2*pi*x2);%行向量
%生成RBF神經(jīng)網(wǎng)絡(luò)
net=newrb(xF0.001);%%%x是輸入,F(xiàn)是目標(biāo)輸出
%?yb=sim(netx);
%?x1=reshape(x12020);
%?x2=reshape(x22020);
%?yb=reshape(yb2020);
%?F=reshape(F2020);
%?figure
%?subplot(131);
%?mesh(x1x2F);
%?subplot(132);
%?mesh(x1x2yb);
%%產(chǎn)生測試數(shù)據(jù)
interval=0.1;
[i?j]=meshgrid(-1.5:interval:1.5);
row=size(i);
tx1=i(:);
tx1=tx1‘;
tx2=j(:);
tx2=tx2‘;
tx=[tx1;tx2];%三維空間的平面測試坐標(biāo)(xy),兩行
%testing
ty=sim(nettx);%把測試坐標(biāo)輸入,進(jìn)行逼近
v=reshape(tyrow);
figure
subplot(132)
mesh(ijv);
title(‘預(yù)測圖像‘)
zlim([060])
%plot?the?original?function
interval=0.1;
[x1?x2]=meshgrid(-1.5:interval:1.5);
F?=?20+x1.^2-10*cos(2*pi*x1)+x2.^2-10*cos(2*pi*x2);
subplot(131)
mesh(x1x2F);
title(‘實際數(shù)據(jù)‘)
zlim([060])
%plot?the?error
subplot(133)
mesh(x1x2F-v);
title(‘誤差‘)
zlim([060])
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????1166??2013-11-29?20:48??rbf_approx.m
?????文件????????5655??2013-11-28?12:47??SVM_approx.m
評論
共有 條評論