Binary-Classification / Matlab / PR_nn.m
PR_nn.m
Raw
clear all;
clc;
filename = 'm_n_ph2_fara.xlsx';
col1 = xlsread(filename,'1:7');
%pattern
col2 = xlsread(filename,'8:8');
x = col1;
t = col2;
trainFcn = 'trainlm';  % Scaled conjugate gradient backpropagation.
% by default function='crossentropy',
hiddenLayerSize =10;
net = patternnet(hiddenLayerSize, trainFcn);
net.divideParam.trainRatio =70/100;
% net.divideParam.valRatio = 15/100;
net.divideParam.testRatio = 30/100;
[net,tr] = train(net,x,t);
y = net(x);
e = gsubtract(t,y);
performance = perform(net,t,y);
tind = vec2ind(t);
yind = vec2ind(y);
percentErrors = sum(tind ~= yind)/numel(tind);
[tpr,fpr,thresholds] = roc(t,y);
[c,cm,ind,per] = confusion(t,y);
TP_N=cm(1,1);
FP_N=cm(2,1);
FN_N=cm(1,2);
TN_N=cm(2,2);
V=[TP_N, FP_N,FN_N,TN_N];