how to calculate the classification accuracy in neural network toolbox?

48 ビュー (過去 30 日間)
Mallikarjun Yelameli
Mallikarjun Yelameli 2017 年 5 月 9 日
コメント済み: Joana 2020 年 7 月 2 日
net=patternnet(10);
[net,tr]=train(net,inputs,targets);
outputs=net(inputs);
[values,pred_ind]=max(outputs,[],1);
[~,actual_ind]=max(targets,[],1);
accuracy=sum(pred_ind==actual_ind)/size(inputs,2)*100;
Is this correct way to calculate the classification accuracy??
  2 件のコメント
Muhammad Shahzaib
Muhammad Shahzaib 2019 年 5 月 23 日
Yes, this is the correct way to calculate the accuracies, (but some times you need to round off the third decimal place to get the exact value.)
For, TEST accuracy :-
[~,pred_ind_tst]=max(outputs(:,[tr.testInd]),[],1);
[~,actual_ind_tst]=max(targets(:,[tr.testInd]),[],1);
Test_accuracy =sum(pred_ind_tst==actual_ind_tst)/size(targets(:,[tr.testInd]),2)*100
Double check your calculation using below:
plotconfusion(targets(:,[tr.testInd]),outputs(:,[tr.testInd]),'Test_accuracy ');
Joana
Joana 2020 年 7 月 2 日
Hi
I tried the above code for calculating test accuracy and double checked with plotting confusion matrix, but the accuracy comes out to be 100% while confusion matrix gives 58.3%.
How i can save the actual test accuracy.?

サインインしてコメントする。

採用された回答

Greg Heath
Greg Heath 2017 年 5 月 11 日
Search ot NEWSGROUP and ANSWERS with
greg patternnet
and
greg patternnet tutorial
Hope this helps.
Thank you for formally accepting my answer
Greg

その他の回答 (2 件)

Santhana Raj
Santhana Raj 2017 年 5 月 9 日
There are various parameters that can and are used in different classification algorithms. Take a look at this wiki page:
Most generally used terms are precision, recall, true negative rate, accuracy. The most widely used is F-measure. The wiki page gives the formula for this. You can shoose one based on your application.

Saira
Saira 2020 年 6 月 15 日
Hi,
I have 5600 training images. I have extracted features using Principal Component Analysis (PCA). Then I am applying CNN on extracted features. My training accuracy is 30%. How to increase training accuracy?
Feature column vector size: 640*1
My training code:
% Convolutional neural network architecture
layers = [
imageInputLayer([1 640 1]);
reluLayer
fullyConnectedLayer(7);
softmaxLayer();
classificationLayer()];
options = trainingOptions('sgdm', 'Momentum',0.95, 'InitialLearnRate',0.0001, 'L2Regularization', 1e-4, 'MaxEpochs',5000, 'MiniBatchSize',8192, 'Verbose', true);

カテゴリ

Help Center および File ExchangeImage Data Workflows についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by