I have a problem. Please help !

how to train my some data series. i.e I have data beban=5,10,15,20,25,30,35,40,45,50 and penduduk=100,200,300,400,500,600 and ekonomi=50000,100000,150000,200000,250000,300000. how to make matrix input in workspace and the script if my script like this?Because my input here just use one data variable. P is input, T is target. My data is like the picture until 52 to the right. Thank you so much for the help
clear;
clc;
load DataPelatihan2.mat;
%%Preprocessing
P=Data2(:,1:42)';
T=Data2(:,43:54)';
[pn,meanp,stdp,tn,meant,stdt] = prestd(P,T);
%%Menentukan Parameter
hiddenlayer1max = 13;
hiddenlayer2max = 11;
error = 1;
errormax = 0;
modmse = 2e2;
epochs = 1000;
% Pelatihan hidden layer 1
for l1=1:hiddenlayer1max;
if error > errormax ;
net=newelm(minmax(pn),[l1 12],{'tansig','purelin'});
%parameter pelatihan
net.trainfcn = 'trainlm';
net.trainParam.show = 50;
net.trainParam.lr = 0.1;
net.trainParam.epochs = epochs;
net.trainParam.goal = errormax;
net.trainParam.max_fail = 500;
net.trainParam.min_grad = 1e-10;
net.trainParam.mc = 0.5;
net.performFcn = 'mse';
%Menampilkan Jumlah Neuron
disp([' Hidden Layer I, Jumlah Neuron = ' num2str(l1)]);
%Train
[netRec,tr]= train(net, pn, tn);
%Simulasi Hasil
Rec= sim(netRec,pn);
%Hitung mse
error=mse(Rec-tn);
%error(l1)=error; %cek
%Ambil Network yg terbaik
if modmse > error;
layerRec=l1;
modmse=error;
hl=1;
save training.mat;
end
else
layer1=11;
break;
end
end
% Pelatihan hidden layer 2
for l2=1:hiddenlayer2max;
if error > errormax ;
net=newelm(minmax(pn),[l1 l2 12],{'tansig','tansig','purelin'});
%parameter pelatihan
net.trainfcn = 'trainlm';
net.trainParam.show = 50;
net.trainParam.lr = 0.1;
net.trainParam.epochs = epochs;
net.trainParam.goal = errormax;
net.trainParam.max_fail = 500;
net.trainParam.min_grad = 1e-10;
net.trainParam.mc = 0.5;
net.performFcn = 'mse';
%Menampilkan Jumlah Neuron
disp([' Hidden Layer II, Jumlah Neuron = ' num2str(l2)]);
%Train
[netRec,tr]= train(net, pn, tn);
%Simulasi Hasil
Rec= sim(netRec,pn);
%Hitung mse
error=mse(Rec-tn);
%error(l2)=error; %cek
%Ambil Network yg terbaik
if modmse > error;
layerRec=l2;
modmse=error;
hl=2;
save training.mat;
end
else
layer2=12;
break;
end
end
%%Mengambil network yg terbaik
load training.mat;
an= sim(netRec,pn)
bs= [layerRec modmse]
a = poststd(an,meant,stdt);
disp('Network terbaik dengan error terkecil');
disp(['Hidden Layer ke ' num2str(hl),', Neuron = ' num2str(layerRec),', Error = ' num2str(modmse)]);
%Regression Diagram
plotregression(a,T);

Answers (0)

Products

Asked:

on 18 Jul 2018

Edited:

on 18 Jul 2018

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!