% 使用平台 - Matlab2009b
clc
clear
close all
%--------------------------------------------------------------------------
% 下载数据
input=[598.9 45.8 291.5 261.6 408.3 2071 2424136.95 192 26804
709.1 49.1 345.9 314.1 503 2375 2498240.73 266 27707
886.2 53.7 419.6 412.9 611.2 3206 2791699.698 410.4 29865
1145.3 67.5 517.6 560.2 766.6 4508 2888078.905 648.8 30825
1507.7 73.5 645.8 788.4 950.4 5663 3703512.854 841.5 32184;
1789.2 75 714.7 999.5 1061.6 6497 2931833.473 876.9 32907;
2077.1 77.2 781.8 1218.1 1208.5 7418 3038852.093 961.2 32351;
2377.2 77.9 840.6 1458.7 1373.6 7954 3050608.191 1155.6 30127;
2678.8 78.4 907.3 1693.1 1509.3 8598 3435951.121 1170.6 28275;
3161.7 79.3 1033.3 2049.1 1658.7 8820 4940040.626 1297.4 30717;
3708 80.8 1142.4 2484.8 1831.4 9057 5149808.576 1530.5 30607;
4315 82.4 1250 2982.6 2005.2 10882 5250528.75 1814.3 30961;
5007.2 84.1 1487.2 3435.9 2296.9 12014 6850016.969 2157.1 30925;
6033.2 87.4 1853.6 4092.2 2626.6 13425 9457572.485 2528.3 31700;
6969.5 88.7 2026.5 4854.3 2911.7 14662 12550642.53 2827.2 32509;
8117.8 88.8 2191.4 5837.6 3295.3 16487 15803662.77 3371.5 33547;
9846.8 101.3 2509.4 7236.1 3835.2 18553 19299976.1 3966.6 20770;
11115 112.8 2626.4 8375.8 4645.5 20113 27169289.87 3848.5 21885;
12153 118.3 2855.5 9179.2 5309.9 22023 21479102.87 4858.4 22017;
14113.6 124.4 3388.4 10600.8 6229.3 24982 30166129.04 5493.5 23712];
output=[27707 29865 30825 32184 32907 32351 30127 28275 30717 30607 30961 30925 31700 32509 33547 20770 21885 22017 23712 26849]';
%--------------------------------------------------------------------------
% 训练样本
input_train=input(1:16,1:9)';
output_train=output(1:16,:)';
% 测试样本
input_test=input(17:20,1:9)';
output_test=output(17:20,:)';
% 样本归一化
[inputn,inputps]=mapminmax(input_train);
[outputn,outputps]=mapminmax(output_train);
%--------------------------------------------------------------------------
P = inputn;
T = outputn;
spread=1 % 此值越大,覆盖的函数值就大(默认为1)
net = newrbe(P,T,spread);
% 模型训练
an1=sim(net,inputn);
% 数据预测
inputn1=mapminmax('apply',input_test,inputps);
an2=sim(net,inputn1);
output2=mapminmax('reverse',an2,outputps);
err1 = output_test-output2;
display('-----------------------预测值与实际值的绝对误差及相对误差---------------------------')
err1
display('-----------------------预测值---------------------------')
output2
%--------------------------------------------------------------------------
figure;
subplot(211);
plot(2008:2011,output_test,'r+:',2008:2011,output2,'bo-');
title('真实值(+)与预测值(o)')
subplot(212);
plot(2008:2011,err1,'k')
title('预测绝对误差')