how to test and improve multi layer perceptron

My project is about apnea detection based on ECG features; I have 11 features for each ECG and my data set is 100 Apnea and 100 normal signal. I choosed newff to implement the classifier with one hidden layer of 8 neurons and I have divided the data into training and testing. The problem is that I assumed '1' as apnea target and '0' as normal target but when it comes to testing the output is not convenient at all Here is my code where R is the training set,T is its target and S is the testing set
function[Output,trained_net,stats]= net_train(R,T,S)
net = newff(R', T, [8], {'tansig' 'logsig'}, 'traingd', ... '', 'mse', {}, {}, '');
net=init(net);
net.trainparam.min_grad=0;
net.trainparam.epochs=1000;
[trained_net,stats]=train(net,R',T);
Output=sim(trained_net,S');
end

2 Comments

Please explain why the {0,1} target is giving you problems.
It shouldn't.
I improved my algorithm and when training I reached 95% accuracy but the testing is still not working (almost 35%).
function[Y,net]=MLPNN(R,T,S)
rand('seed', 672880951)
net = newff(minmax( R ),[11,11,1],{'tansig','logsig','logsig'});
net.trainFcn='trainscg';
net.trainParam.epochs=1000;
net=train(net,R,T);
Y=round(sim(net,S));
end
R the training data is composed of 50 consecutive apnea records and 50 consecutive normal records and so does the testing data S.
the output should be like [ones(1,50) zeros(1,50)] but it does not. Any idea?

Sign in to comment.

 Accepted Answer

NEWPR is the version of NEWFF that should be used for classification/pattern-recognition
Remove ending semicolons to see command line printout:
target = ind2vec(trueclassindices);% Use for training
trueclassindices = vec2ind(target);
...
output = net(input);
predictedclassindices = vec2ind(output);
err = predictedclassindices ~= trueclassindices; % ones and zeros
Nerr = sum(err);
PctErr = 100*Nerr/N
classification breakdowns of the trn/val/tst subsets can be obtained using the training record tr obtained from
[ net tr output error ] = train(net,input,target);
% output = net(input);
% error = target-output;
tr = tr % No semicolon to see the goodies
Hope this helps.
Thank you for formally accepting my answer
Greg

1 Comment

thanks for helping it worked but i have another question.
Now i'm using newrb to classify using Radial basis but it immediately reaches minimum gradient. What do i have to change?
Thank you for your help

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!