This is my data file
Why the accuracy in testing phase of ANN difference for matlab 2010 and 2018
1 view (last 30 days)
Show older comments
%Read the data file
pt=xlsread('Data normalize.xls');
p1=pt(1:893,1:4);
t1=pt(1:893,5);
%Make the transpose of the input and output pattern
p=p1';
t=t1';
rand('state',1);
%Set the network architecture
%Both the hidden and the output layer neurons are activated by binary sigmoidal activation function.
%net=newff(minmax(p),[Hidden Node Number Column Target],{'tansig' 'tansig'},'trainlm');
%Training parameters=Levenberg-Marquardt
net=newff(minmax(p),[10 1],{'tansig' 'tansig'},'trainlm');
%Set the training parameters
net.trainParam.epochs=j;
net.trainParam.goal=0.0100;
net.trainParam.lr=0.001;
net.trainParam.min_grad=1e-10;
net.trainParam.mu=0.9;
net.trainParam.mu_max=1.0e10;
%Train the network
net=train(net,p,t);
%Save the final weight and the network architecture in net
save net net;
% Validation
%Read the data file
p1=pt(1:893,1:4);
t1=pt(1:893,5);
[m1 n1]=size(p1);
p=p1';
t=t1';
%The data to simulate the network must be of column format
y=sim(net,p);
y';
round(y');
%Compare network response against the desired target response
[y' t' (y'-t')];
[round(y') t' round(y'-t')];
%Build the classification matrix which will provides a comprehensive picture of a classifiers performance
diff_1=[round(y'-t')];
A1=diff_1(:,1);
a_a=length(find((A1==0)));
fprintf('Number of epochs = %d\n',net.trainParam.epochs);
%Classification matrix in number
cm=[a_a m1];
fprintf('Number of Correct Classification : %f\n', (cm(1,1)));
fprintf('Number of Incorrect Classification : %f\n', (cm(1,2)-cm(1,1)));
%Classification matrix in percentages
cm_p=(cm ./ m1) .* 100;
fprintf('Percentage of Correct Classification : %f%%\n', 100*(cm(1,1))/m1);
fprintf('Percentage of Incorrect Classification : %f%%\n', 100*(cm(1,2)-cm(1,1))/m1);
%% Harumanis Classification
%Bayesian Regulation
%Not-healthy=0, Healthy=1
%clc;
%clear all;
%close all;
%% Testing the Classifier
%Read the master data file
pt=xlsread('Data normalize.xls');
[m n]=size(pt);
%Read the data file
p1=pt(894:1488,1:4);
t1=pt(894:1488,5);
[m1 n1]=size(p1);
p=p1';
t=t1';
%Load the final weight and simulate the output(y)
load net net;
%The data to simulate the network must be of column format
y=sim(net,p);
y';
round(y');
%Compare network response against the desired target response
[y' t' (y'-t')];
[round(y') t' round(y'-t')];
%Build the classification matrix which will provides a comprehensive picture of a classifiers performance
diff_1=[round(y'-t')];
A1=diff_1(:,1);
a_a=length(find((A1==0)));
%Classification matrix in number
cm=[a_a m1];
fprintf('Number of Correct Classification : %f\n', (cm(1,1)));
fprintf('Number of Incorrect Classification : %f\n', (cm(1,2)-cm(1,1)));
%Classification matrix in percentages
cm_p=(cm ./ m1) .* 100;
fprintf('Percentage of Correct Classification : %f%%\n', 100*(cm(1,1))/m1);
fprintf('Percentage of Incorrect Classification : %f%%\n', 100*(cm(1,2)-cm(1,1))/m1);
end
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!