Matlab GRNN神经网络建模过程
输出数据
load data inputData outputData
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%神经网络求取
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
inputl
=inputData(:,1:7)'
;
%outputl
=outputData(:,1)'
;
outputl
=outputData'
;
input_train
=inputl(:,1:229);
output_train
=outputl(:,1:229);
input_test
=inputl(:,230:263);
output_test
=outputl(:,230:263);
[P_train,inputps
]=mapminmax(input_train
);
[T_train,outputps
]=mapminmax(output_train
);
spread
=1;
net_grnn
= newgrnn(P_train
,T_train
,spread
);
P_test
=mapminmax('apply',input_test
,inputps
);
gg
= sim(net_grnn
,P_test
);
Bt
=mapminmax('reverse',gg
,outputps
);
error2
=(Bt
-output_test
)./output_test
;
r
=corrcoef(Bt
,output_test
);
x
=1:34;
%plot(x
,error
,'o');
% plot(x
,error(1,:),'o-',x
,error(2,:),'s-',x
,error(3,:),'^-');
% xlabel('样品编号');
% ylabel('相对误差')
% h1
=legend('端面距离1','端面距离2','端面距离3','location','North');
% set(h1
,'Box','off','Orientation','horizon')
%
% figure
;
plot(Bt(2,:),output_test(2,:),'*');
figure
;
plot(Bt(1,:),output_test(1,:),'*',Bt(2,:),output_test(2,:),'d',Bt(3,:),output_test(3,:),'+');
h1
=legend('4.7mm','7.9mm','12.7mm','location','North');
set(h1
,'Box','off','Orientation','horizon')
xlabel('预测值');
ylabel('实验值')
text(27,40,'R=0.9789')
text(27,41,'speed=1')
%
% %R
= corrcoef(Bt
,output_test
)
% mr
=corrcoef(Bt
',output_test');
% save speed2 error2
## 窗口设置
后面是一段设置XY坐标显示格式的代码,仅供参考
%
% X
=[ones(54,1),output_test(1,:)'
]
% y
=Bt(1,:)'
% [b
,bint
,r
,rint
,stats
]=regress(y
,X
);
% plot(x
,y
,'o-',x
,yy
,'s-');
% %xticks(5:16);
% %set(gca
,'xticklabel',{'4','5','6', '7', '8', '9', '10', '11', '12', '13','14', '15','16'});
% % plot(xx
,y1
,'+-',xx
,y2
,'o-');
% axis([4 17 0.04 0.1])
% xlabel('Number of Hidden Neurons');
% %set(gca
,'xticklabel',{'0','1.5','3', '5', '7', '9', '11', '13', '15', '20','25'});
% ylabel('Rmax of 1000 cycles')
% %h1
=legend('Min','Mean','Std','location','North');
% h1
=legend('Min','Mean','location','North');
% set(h1
,'Box','off','Orientation','horizon')
转载请注明原文地址: https://lol.8miu.com/read-21417.html