How to get Precision, Recall,ROC,F_Mesure?
조회 수: 2 (최근 30일)
이전 댓글 표시
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?.
댓글 수: 0
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Image Data Workflows에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!