i want to calculate precision , recall , f-score and …., but i get this erro:
Undefined function 'diag' for input arguments of type 'mlearnlib.graphics.chart.ConfusionMatrixChart'.Error in SHIVANaugmented (line 74)tp_m = diag(cm);==============================================the following is a part of my code:cm=confusionchart (imdsValidation.Labels, YPred);%%
tp_m = diag(cm); for i = 1:2 % number of classes
TP = tp_m(i); FP = sum(cm(:, i), 1) - TP; FN = sum(cm(i, :), 2) - TP; TN = sum(cm(:)) - TP - FP - FN; Accuracy = (TP+TN)./(TP+FP+TN+FN); TPR = TP./(TP + FN);%tp/actual positive RECALL SENSITIVITY
if isnan(TPR) TPR = 0; end PPV = TP./ (TP + FP); % tp / predicted positive PRECISION
if isnan(PPV) PPV = 0; end TNR = TN./ (TN+FP); %tn/ actual negative SPECIFICITY
if isnan(TNR) TNR = 0; end FPR = FP./ (TN+FP); if isnan(FPR) FPR = 0; end FScore = (2*(PPV * TPR)) / (PPV+TPR); if isnan(FScore) FScore = 0; endend%%save youRnetwork net
Best Answer