I am working on Electromyogram signals to classify 11 different hand movements using ANN. My code is as follow:
load FeatureSet;p=input; %[16 by 1342 ]
t=target; %[11 by 1342]
trainFcn = 'trainbr'; % Use Bayesian Regularization to prevent overtraining
net = patternnet([32 32], trainFcn);net.layers{1}.transferFcn = 'tansig'; % hidden layer 1
net.layers{2}.transferFcn = 'logsig'; % hidden layer 2
% %------------------------parameter
net.trainParam.lr = 0.1; %learning rate
net.trainParam.mc = 0.1; %momentum
%------------------------ train
[net,tr]= train(net,p,t);%------------------------ test
outputs= sim(net,P);[c,cm] = confusion(t,outputs);pct=100*(1-c); %correction rate
1) I am trying to normalize the input between 0 to +1 but I am not sure if it is needed. Dose patternnet do anything regarding the normalization of the input? my data range is between 0.1 to 120.
normalized_p=[]; for ii=1:length(p(1,:)) norm_p=[]; Max_p(ii)=max(p(:,ii)); Min_p(ii)=min(p(:,ii)); norm_p = (p(:,ii) - Min_p(ii))./(Max_p(ii) - Min_p(ii)); normalized_p=[normalized_p, norm_p]; end
2) I get the following warning when using patternnet:
Warning: Performance function replaced with squared error performance. > In trainbr>formatNet (line 160) In trainbr (line 69) In nntraining.setup (line 14) In network/train (line 335) In ANN_demo (line 95)
I also used newpr, but I did not get any warning.
3) Patternnet divides data into three sets which are training, validation and testing. I found the following code to get the performance of the classifier but I do not know how to calculate the correction rate of each set.
RandStream.setGlobalStream(RandStream('mt19937ar','seed',1)); % to get constant result
net.divideFcn = 'divideblock'; % Divide targets into three sets using blocks of indices
net.divideParam.trainRatio = 0.6;net.divideParam.valRatio = 0.2;net.divideParam.testRatio = 0.2;%------------------------ train[net,tr]= train(net,p,t);%------------------------ testoutputs = net(p);performance = perform(net,t,outputs) trainTargets = t .* tr.trainMask{1};valTargets = t .* tr.valMask{1};testTargets = t .* tr.testMask{1};trainPerformance = perform(net,trainTargets,outputs)valPerformance = perform(net,valTargets,outputs)testPerformance = perform(net,testTargets,outputs)
4) I want to compare the result of ANN with some other classifiers such as LDA, SVM , etc. and I am using 10-fold cross validation (9 for training and 1 for testing) for those classifiers. In ANN, the data is divided to three parts (0.6 training 0.2 validation 0.2 testing). How can I evaluate all the methods in the same way. For example 10-fold cross validation for all of them including ANN.
Best Answer