Filter löschen
Filter löschen

How to get Precision, Recall,ROC,F_Mesure?

1 Ansicht (letzte 30 Tage)
Arya Faturrahman
Arya Faturrahman am 12 Okt. 2022
Hello anyone I want to get Precision, Recall, Sensitivity,Sprecificity,ROC. But I don't know how to implements code. i get Error at perfCurve and i don't know to fix it.
This my Train Code
imds = imageDatastore('Dataset', 'IncludeSubfolders', true, 'LabelSource', 'foldernames');
tbl = countEachLabel(imds);
minSetCount = min(tbl{:,2});
imds = splitEachLabel(imds, minSetCount, 'randomize');
countEachLabel(imds);
net = resnet50();
lgraph = layerGraph(net);
clear net;
numClasses = 2;
%numel(lgraph.Layers(end).ClassNames);
[trainingSet, testSet] = splitEachLabel(imds, 0.7, 'randomize');
imageSize = [224 224 3];
augmentedTrainingSet = augmentedImageDatastore(imageSize,...
trainingSet, 'ColorPreprocessing', 'gray2rgb');
augmentedTestSet = augmentedImageDatastore(imageSize,...
testSet, 'ColorPreprocessing', 'gray2rgb');
% New Learnable Layer
newLearnableLayer = fullyConnectedLayer(numClasses, ...
'Name','new_fc', ...
'WeightLearnRateFactor',10,...
'BiasLearnRateFactor',10);
% Replacing the last layers with new layers
lgraph = replaceLayer(lgraph,'fc1000',newLearnableLayer);
newsoftmaxLayer = softmaxLayer('Name','new_softmax');
lgraph = replaceLayer(lgraph,'fc1000_softmax',newsoftmaxLayer);
newClassLayer = classificationLayer('Name','new_classoutput');
lgraph = replaceLayer(lgraph,'ClassificationLayer_fc1000',newClassLayer);
options = trainingOptions('adam',...
'MaxEpochs',6,'MiniBatchSize',8,...
'Shuffle','every-epoch', ...
'ValidationData', augmentedTestSet, ...
'ValidationFrequency', 30, ...
'InitialLearnRate',1e-4, ...
'Verbose',false, ...
'Plots','training-progress');
netTransfer = trainNetwork(augmentedTrainingSet,lgraph,options);
And This my Test code for get the precision and any parameters
YPred = predict(netTransfer, augmentedTestSet); %imds_test is the image dastore containing the test images.
[Xpr,Ypr,Tpr,AUCpr] =perfcurve(testSet, newClassLayer, 1, 'xCrit', 'reca', 'yCrit', 'prec');
[c,cm,ind,per] = confusion(targets,outputs); %per represents the Matrix of percentages. Please refer to the doc for more details.
Can you help me to fix and get the data?.

Antworten (0)

Produkte


Version

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by