Can anyone explain this code line by line?
1 view (last 30 days)
Show older comments
function EVAL = Evaluate(ACTUAL,PREDICTED)
% This fucntion evaluates the performance of a classification model by
% calculating the common performance measures: Accuracy, Sensitivity,
% Specificity, Precision, Recall, F-Measure, G-mean.
% Input: ACTUAL = Column matrix with actual class labels of the training
% examples
% PREDICTED = Column matrix with predicted class labels by the
% classification model
% Output: EVAL = Row matrix with all the performance measures
idx = (ACTUAL()==1);
p = length(ACTUAL(idx));
n = length(ACTUAL(~idx));
N = p+n;
tp = sum(ACTUAL(idx)==PREDICTED(idx));
tn = sum(ACTUAL(~idx)==PREDICTED(~idx));
fp = n-tn;
fn = p-tp;
tp_rate = tp/p;
tn_rate = tn/n;
accuracy = (tp+tn)/N;
sensitivity = tp_rate;
specificity = tn_rate;
precision = tp/(tp+fp);
recall = sensitivity;
f_measure = 2*((precision*recall)/(precision + recall));
gmean = sqrt(tp_rate*tn_rate);
EVAL = [accuracy sensitivity specificity precision recall f_measure gmean];
4 Comments
Jan
on 13 Apr 2019
This is again a very general question. This is a forum to solve Matlab problems. It is not clear, if your question concerns Matlab or the underlying mathematical method. What is the connection to the posted code?
Answers (1)
Image Analyst
on 13 Apr 2019
I think maybe the question has been changed because I don't see any LBP code in the current function (included as an attachment here).
Anyway, the code as posted now is very simple and really doesn't need too much explanation. Already about a third of the function is comments. Maybe just put in your own additional comments in front of each line -- shouldn't be too hard for you. Basically it just goes over the standard ROC Curve measurements, as explained on the Wikipedia page on ROC Curve.
For what it's worth, I'm including my LBP function here as an attachment.
2 Comments
sassouki123
on 13 Apr 2019
Hello ,
I need your help on image processing.
I want to average 30 files.mat each containing 1000 frames.
I want to average Frame1 for the 30 files then frame 2 up to frame 1000 to get at the end a single image that contains 1000 frames
thank you
Walter Roberson
on 13 Apr 2019
Edited: Walter Roberson
on 13 Apr 2019
Awer, that is a different topic. Please open your own Question on that. When you do so, be sure to mention size() of your variables and how the frames are stored in the .mat file.
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!