0% found this document useful (0 votes)
33 views

Datos: %entrenamiento %validación %test

The document loads data and separates it into training (P), validation (val), and test (test) sets for neural network training and evaluation. It trains a feedforward neural network (net) on the training set, evaluates it on the validation and test sets, and outputs the network weights and performance results. Key metrics like correlation coefficient, mean squared error, and root mean squared error are also calculated to evaluate model fit to the data.

Uploaded by

m_michael_c
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views

Datos: %entrenamiento %validación %test

The document loads data and separates it into training (P), validation (val), and test (test) sets for neural network training and evaluation. It trains a feedforward neural network (net) on the training set, evaluates it on the validation and test sets, and outputs the network weights and performance results. Key metrics like correlation coefficient, mean squared error, and root mean squared error are also calculated to evaluate model fit to the data.

Uploaded by

m_michael_c
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 16

load Datos

P=[Datos(:,1) Datos(:,2) Datos(:,3) Datos(:,4) Datos(:,5) Datos(:,6)]';


T=[Datos(:,7)]';
[pn,ps1]=mapstd(P);
[tn,ts] =mapstd(T);
[ptrans,ps2]=processpca(pn,0.001);
S=size(ptrans)
col=S(2);
Clas13=[1:4:col 3:4:col];
Clas4=4:4:col;
Clas2=2:4:col;
Enp= ptrans(:,Clas13); %Entrenamiento
VEt= tn(:,Clas13);
val.P=ptrans(:,Clas4); %Validacin
val.T=tn(:,Clas4);
test.P=ptrans(:,Clas2); %Test
test.T=tn(:,Clas2);
Rango=minmax(ptrans)
net=newff(Rango,[4 1],{'tansig' 'purelin'},'trainlm');
[net,tr]=train(net,Enp,VEt,[],[],val,test);
S =
6

116

Rango =
-3.1562
-3.0519
-2.6926
-2.5985
-3.2619
-2.2389

2.1639
2.3929
3.1526
2.6549
2.2386
2.6427

plot(tr.epoch, tr.perf, tr.epoch, tr.vperf, tr.epoch, tr.tperf)


legend('ENTRENAMIENTO','VALIDACION','TEST',-1);
ylabel('ERROR CUADRTICO');
xlabel('ITERACIN')
title('CURVAS DE ENTRENAMIENTO:')
grid on
net.IW{1,1}
0.8421
-0.2520
0.7487
-0.4751

-0.3526
0.7134
0.0241
-0.8973

-1.0678
0.2061
-0.7584
0.6915

0.1706
-0.4402
-0.0004
0.4367

1.6033
0.0834
0.6075
-1.2870

1.4758
-0.1376
-2.4275
-1.3198

net.b{1,1}
1.6722
0.5429
-1.1105
-1.5443
rn = sim(net,ptrans);
size(rn)
=
1

116

[m,b,r]=postreg(R,T);

format long;
Na=length(R);
mR=mean(R);
mT=mean(T);
VmR=mR*ones(1,Na);
VmT=mT*ones(1,Na);
cR=dot(R-VmR,T-VmT)/(norm(R-VmR)* norm(T-VmT));
MSE=norm(T-R,2)^2/Na;
RMSE=norm(T-R,2)/sqrt(Na);

ESTDIS=[cR,cR^2,MSE, RMSE];
single(ESTDIS)
0.3364747

0.1132153

0.1591381

0.3989212

E=abs(R-T);
M=minmax(E);
a=M(1);
b=M(2);
N=13;
h=(b-a)/(N-1);
for i=1:N
X(i)=a+h*(i-1);
end
Na=length(X);
hist(E,X)
grid on
set(get(gca,'Children'),'FaceColor',[.6 .5 1]);
hold on
ylabel('FRECUENCIA');
xlabel('ERRORES');
title('ERROR ENTRE LA RESPUESTA Y EL VALORESPERADO');
Frr=hist(E,X);
format short;
Frec=[X',Frr']
Frec =
0.0032
0.0895
0.1758
0.2620
0.3483
0.4346
0.5209
0.6071
0.6934
0.7797
0.8660
0.9522
1.0385

13.0000
17.0000
21.0000
19.0000
11.0000
9.0000
4.0000
4.0000
10.0000
2.0000
3.0000
1.0000
2.0000

P=[Datos(:,1) Datos(:,2) Datos(:,3) Datos(:,4) Datos(:,5) Datos(:,6)]';


T=[Datos(:,7)]';
net=feedforwardnet(10);
net=train(net,P,T);
y=net(P);
perf=perform(net,y,T)
perf =
0.1799

net.IW{1,1}
ans =
-0.2090
0.5115
1.1526

0.5248
0.4464
1.3808

0.2296
0.4216
0.2536

-0.6773
-0.1995
-0.6125

1.3144
-1.4830
0.2658

-1.0045
-1.3436
0.6460

-0.5285
0.5080
-0.1459
0.7593
0.8566
-0.8544
0.4370

net.b{1,1}
1.6722
0.5429
-1.1105
-1.5443

-1.2036
-0.4709
-1.0405
1.1033
0.3982
-0.0988
0.5241

0.9620
0.0427
1.3592
-0.7431
-1.1445
-1.2371
-1.4879

0.9499
0.4493
0.6498
1.0429
1.2964
-1.0196
-1.2330

0.0879
1.1547
-0.0169
-0.3300
0.4946
0.6469
0.0969

-0.7589
-1.4615
0.6822
-0.5936
-0.1455
0.4610
-0.4401

You might also like