clear all;
clc;

filename = 'breast' ;
[x] = xlsread(filename,'B1:J699') ;
[t] = xlsread(filename, 'K1:K699') ;
i = 1 ;
j = 1 ;

input = x' ;
mat = t' ;
target = zeros(2,699);


for i=1:699
    if mat(i) == 2
        target(1,i) = 1;
    else
        target(2,i) = 1 ;
    end
end
 
histogram (input)
figure ();
histogram (mat)
figure ();
        

setdemorandstream(3) ;


net = feedforwardnet([5 4 2]);

net.layers{1}.transferFcn = 'hardlim' ;
net.layers{2}.transferFcn = 'tansig' ;
net.layers{3}.transferFcn = 'tansig'  ;

net.divideParam.trainRatio = 66/100;
net.divideParam.valRatio = 17/100;
net.divideParam.testRatio = 17/100;

[net,tr] = train(net,input,target) ;

plotperform(tr)

 testX = input(:,tr.testInd) ;
 testT = target(:,tr.testInd) ;
 testY = net(testX) ;
 
 dif = (testT - testY) ;
 er = zeros(1,119);

 
 for i=1:119
     if (dif(i) > 0.8 || dif(i)< -0.8)
         j = j + 1 ;
         er(i) = 1 ;
     end
 end
 

output = sim(net,input);
plotconfusion(target,output);
figure () ;
plotroc(target,output) ;
