基于神经网络的未知未来预测

4次浏览(最近30天)
Hatice GENC卡瓦根
Hatice GENC卡瓦根 2019年4月14日
你好,我想预测未来(2018-2038年)的消费价值。但是我猜我的代码出了问题。这是消费的时间序列。我可以拟合真实样本和预测样本的高得分(如%99)。但是当我走到最后(预测部分),在接近2或4步后,值开始是相同的。我认为这是正常化,因为消费必须增加,因为它的过去和最大值是1,所以值不能进一步,它保持在1以下。当我使用另一个代码的规范化,如Xn=规范化(Xn)网络找不到任何相关(NaN)。
除此之外,当我用这种方法进行标准化时,我如何去标准化样本。训练后的最大值和最小值是什么?我正在写下面的代码。提前谢谢。
十五=负载(“elektriktek.txt”);
xn =十五';
xn = (xn-min (xn)) / ((max (xn)分钟(xn)));
人物,情节(xn)
data = [xn (1,1: end-10); xn(1、2:end-9); xn (1, 3: end-8); xn (1, 4: end-7); xn(1、5:end-6); xn(1, 6:录得5个);xn (1 7: end-4); xn(1日8:end-3); xn(1日9:end-2); xn (1, 10: end-1)]; % % % % 5 giriþ1 ileri tahmin
组= xn(1、11:结束);
data =数据”;
组=组”;
指数= crossvalind (Kfold,长度(数据),3),% % % %
TestMSE_toplam = 0 (3,1);
TestMAE_toplam = 0 (3,1);
因为I = 1:3
Testy = (indices == i);
暴躁的=暴躁的;
trainy =(~暴躁的);
trainy = trainy;
TestInputData =数据(暴躁的,:)”;
TrainInputData =数据(trainy:) ';
TestOutputData =组(暴躁的,:)”;
TrainOutputData =组(trainy:) ';
Tahmin = 0(大小(TestOutputData));
Ref = 0(大小(TestOutputData));
m = 1:10
兰特(“种子”,1);
randn(“种子”,1);
网= newff(极大极小(TrainInputData (:,)), [m 1],{‘tansig’,‘tansig’,‘purelin},“trainlm”);
net.trainParam.epochs = 300;
net.trainParam.show = 20;
% net.trainparam.lr = 0.01;
net.trainparam.goal = 0.00001;
(净,tr) =火车(网,TrainInputData, TrainOutputData);
TrainOutput = sim(净,TrainInputData);
TrainMSE (m, 1) = mse (TrainOutputData-TrainOutput);
TrainMAE (m, 1) =美(TrainOutputData-TrainOutput);
TrainReport = [TrainOutput '];
TestOutput = sim(净,TestInputData);
TestMSE (m, 1) = mse (TestOutputData-TestOutput);
TestMAE (m, 1) =美(TestOutputData-TestOutput);
火车离站时刻表(m, 1) = (tr.time)之和;
结束;
(a2, b2) =找到(TestMSE = = min (min (TestMSE)));
(ax, bx) =找到(a2 = = min (a2))
a2 = a2 (ax, bx)
b2 = b2 (ax, bx)
axx(我,1)= a2;
bxx(我,1)= b2;
TestMSE_son (1) = TestMSE (a2, b2);
TestMAE_son (1) = TestMAE (a2, b2);
traintime_son(1) =火车离站时刻表(a2, b2);
%的人物,情节(TestOutputData ' O ');抓住;情节(TestOutput,‘*’);推迟
兰特(“种子”,1);
randn(“种子”,1);
网= newff(极大极小(TrainInputData (:,)), (a2(1){‘tansig’,‘tansig’,‘purelin},“trainlm”);
net.trainParam.epochs = 500;
net.trainParam.show = 20;
% net.trainparam.lr = 0.01;
net.trainparam.goal = 0.00001;
(净,tr) =火车(网,TrainInputData, TrainOutputData);
TestOutput = sim(净,TestInputData);
TestMSE_son (1) = mse (TestOutputData-TestOutput)
TestMAE_son(1) =美(TestOutputData-TestOutput)
TrainMSE_son (1) = mse (TrainOutputData-TrainOutput)
TrainMAE_son(1) =美(TrainOutputData-TrainOutput)
R2 = corrcoef (TestOutputData TestOutput);
R2 R22(1) =(1、2)^ 2
(m1, n1, r) = postreg (TestOutputData TestOutput);
注册(我,1)= r;
人物,情节(TestOutputData ' - o ');抓住;情节(TestOutput - *);推迟
Tahmin = Tahmin + TestOutput;
Ref = Ref + TestOutputData;
结束;
Tahmin_Test = Tahmin / 3;
Ref_Data = Ref / 3;
%%%%%%%%%%%%%%%%%%
TestMSE = (sum (TestMSE_son)) / 3
TestMAE = (sum (TestMAE_son)) / 3
TrainMSE = (sum (TrainMSE_son)) / 3
TrainMAE = (sum (TrainMAE_son)) / 3
Corr_R = (sum (R22)) / 3
Reg_R = ((Reg)) / 3和
人物,情节(Ref_Data);坚持;情节(Tahmin_Test ' r ')
fid1 = fopen (' hatalar_ysa.txt ', ' w + ');
流(fid1 TestMSE = % 12.6 f \ n, TestMSE);
流(fid1 TestMAE = % 12.6 f \ n, TestMAE);
流(fid1 TrainMSE = % 12.6 f \ n, TrainMSE);
流(fid1 Corr_R = % 12.6 f \ n, Corr_R);
流(fid1 Reg_R = % 12.6 f \ n, Reg_R);
米克塔= 20%米克塔表示步长
tahmin = 0 (miktar, 1);% Tahmin意味着预测
test1 = [xn(1、end-9); xn (1, end-8); xn (1, end-7); xn (1, end-6); xn(1,录得5个);xn (1, end-4); xn (1, end-3); xn (1, end-2); xn (1, end-1); xn (1)];
因为我= 1:miktar;
tahmin (1) = sim(网络,test1);
testn test1 (1, - 1) = (2, 1);
testn (2, 1) = test1 (3,1);
testn test1 (3,1) = (4,1);
testn test1 (4,1) = (1);
testn test1(5、1)= (6,1);
testn (6,1) = test1 (7, 1);
testn test1 (7 - 1) = (1);
testn test1 (8 - 1) = (9,1);
testn test1 (9,1) = (1);
testn (10 - 1) = tahmin(我,1);
test1 = testn
结束;
人物,情节(tahmin)

接受的答案

BERGHOUT Tarek
BERGHOUT Tarek 2019年4月16日
我附加了这个文件,使用这个函数,它是伟大的正常化,但在你正常化你的数据之间的0和1,我的意思是在训练之前尝试做:
加载你的数据
保存下面的参数,因为你将在以后的反规格化中需要它们:
-如果你的数据是一个矩阵,那么Xmin=(min(min(data));
如果你的数据是一个矢量,就用一个Max和一个min;
3-规范化数据之间的0和1;
4-训练你的数据并得到你的输出,
输出=scaledata(output,Xmin,Xmax);
请接受我的回答,如果它是有帮助的。
1评论
Hatice GENC卡瓦根
Hatice GENC卡瓦根 2019年4月17日
谢谢你,我把代码后加载数据,我用两种方式为矩阵和vextor。但我不能同时使用它们来得到相关性
我是这样写的;
Xmin = (min (min (xn))); Xmax = (max (max (xn)))
normalize2.png

登录评论。

更多的答案(0)

社区寻宝

在MATLAB中心找到宝藏,并发现社区如何可以帮助你!

开始狩猎!