经管之家送您一份
应届毕业生专属福利!
求职就业群
感谢您参与论坛问题回答
经管之家送您两个论坛币!
+2 论坛币
- 我用600个数据训练下面这个网络,但是不知道最后训练好后,如何进行预测,哪位大虾可以帮忙一下。。。写出最后的预测代码。。。。谢谢啦。。。 numPts=600;
- trnData=data(1:2:numPts,:); %训练数据集
- chkData=data(2:2:numPts,:); %检验数据集
- %绘制检验数据集和检验数据集的分布图
- figure;
- epoch=1:300;
- plot(epoch,trnData(:,3),'o',epoch,chkData(:,3),'kx');
- legend('训练数据集','检验数据集');
- fismat = genfis1(data,[2 3],char('gaussmf','gaussmf'));%采用网格方式生成初始Sugeno型模糊推理系统
- %隶属度函数选用高斯函数
- figure; %绘制初始隶属度函数曲线
- [x,mf]=plotmf(fismat,'input',1);
- subplot(2,2,1),plot(x,mf);
- xlabel('input 1 (gaussmf)');
- [x,mf]=plotmf(fismat,'input',2);
- subplot(2,1,2),plot(x,mf);
- xlabel('input 2 (gaussmf)');
- title('初始隶属度函数');
- numEpochs = 130; %训练次数为40
- %利用自适应神经算法进行模糊系统的训练(参数学习),采用反向传播算法
- [fismat1,trnErr,ss,fismat2,chkErr] = anfis(trnData,fismat,numEpochs,NaN,chkData,1);
- %计算训练后神经网络模糊系统的输出与训练数据的均方根误差
- trnOut = evalfis([trnData(:,1) trnData(:,2)]',fismat1);
- trnRNSE = norm(trnOut - trnData(:,3)) / sqrt(length(trnOut));
- figure;
- epoch=1:numEpochs
- plot(epoch,trnErr,'o',epoch,chkErr,'kx');
- %绘制训练过程中的最小二乘误差变化情况,如果和核对数据的误差同时减小,
- %模型才是有效的
- legend('训练数据误差','校验数据误差');
- hold on;
- plot(epoch,[trnErr chkErr]);
- hold off;
- %下面绘制训练后模糊推理系统的隶属度函数曲线
- figure;
- [x,mf]=plotmf(fismat1,'input',1);
- subplot(2,2,1),plot(x,mf);
- xlabel('input 1 (gaussmf)');
- [x,mf]=plotmf(fismat1,'input',2);
- subplot(2,1,2),plot(x,mf);
- xlabel('input 2 (gaussmf)');
- title('训练后的隶属度函数');
- %绘制训练后的神经网络模糊推理系统的输入/输出分布图
- figure;
- anfis_y=evalfis([data(:,1) data(:,2)]',fismat1);
- epoch=1:600;
- plot(epoch,data(:,3),'o',epoch,anfis_y,'kx');
- legend('原始数据集','结果模糊系统曲线');
复制代码
扫码加我 拉你入群
请注明:姓名-公司-职位
以便审核进群资格,未注明则拒绝
|