figure
load ESTSP2007_competition_data.dat;
a=ESTSP2007_competition_data;
plot(a,'r:*')
xlabel('week','fontsize',12);ylabel('temperature'...
,'fontsize',14);
trn_data = zeros(475, 5);
chk_data = zeros(400, 5);
% prepare training data
trn_data(:, 1) = a(1:475);
trn_data(:, 2) = a(7:481);
trn_data(:, 3) = a(13:487);
trn_data(:, 4) = a(19:493);
trn_data(:, 5) = a(25:499);
% prepare checking data=
chk_data(:, 1) = a(449:848);
chk_data(:, 2) = a(455:854);
chk_data(:, 3) = a(461:860);
chk_data(:, 4) = a(467:866);
chk_data(:, 5) = a(473:872);
% The initial MFs for training are shown in the plots.
fismat=genfis1(trn_data,[2,2,2,2],char('gbellmf','trimf','trimf','pimf'),'constant');
% for index=1:4,
% subplot(2,2,index)
% [x,y]=plotmf(fismat,'input',index);
% plot(x,y)
% axis([-inf inf 0 1.2]);
% xlabel(['Input ' int2str(index)],'fontsize',10);
% end
figure
[trn_fismat,trn_error,step,chkfis,chk_error] = ...
anfis(trn_data, fismat,[15 NaN 0.01 1],[1 1 1 1],chk_data,1)
% plot final MF's on x, y, z, u
for input_index=1:4,
subplot(2,2,input_index)
[x,y]=plotmf(trn_fismat,'input',input_index);
plot(x,y)
axis([-inf inf 0 1.2]);
xlabel(['Input ' int2str(input_index)],'fontsize',10);
end
% error curves plot
epoch_n = 10;
plot([trn_error chk_error,]);
hold on; plot([trn_error chk_error], 'or'); hold off;
xlabel('Epochs','fontsize',10);
legend('trn_error','chk_error',0);
ylabel('RMSE (Root Mean Squared Error)','fontsize',10);
title('Error Curves','fontsize',10);
%comparision
input = [trn_data(:, 1:4); chk_data(:, 1:4)];
anfis_output = evalfis(input, trn_fismat);
index = 1:875;
figure
plot(index,[a(index) anfis_output]);
title('comparision');
xlabel('week','fontsize',10);
ylabel('temp','fontsize',20);
legend('original','predicted');
% % Prediction errors of ANFIS
% % figure
% diff=a(index)-anfis_output;
% % plot(index,diff);
% xlabel('week');
% title('ANFIS prediction errors','fontsize',15);
enso.rar_ANFIS_ANFIS matlab_anfis matlab_weather_weather matlab
版权申诉
47 浏览量
2022-09-21
08:49:27
上传
评论
收藏 922B RAR 举报
我虽横行却不霸道
- 粉丝: 76
- 资源: 1万+