Info

This question is closed. Reopen it to edit or answer.

Is there any function similar or better than isequal to solve comparison problem

1 view (last 30 days)
Hi, I hope somebody can help me eventhough this is kind of algorithm problem using isequal.Let say there is a dataset of 3 columns;col1 stores petal length, col2 stores actual class and col3 stores predicted class.There are 3 classes in this dataset.
PL actual predicted
1 2 2
1.1 2 2
1.2 2 2
1.2 3 2
1.3 1 3
Row/Interval 1:3, FP error=0; which is correct.
Row/Interval 4:5, FP error /missclassify produce errors.
FPcost has correct answer for all intervals.
e.g when actual class=1
I expect in interval 4:5, when missclassify as class2 although actual class is 1, FPerror=0
I expect in interval 4:5, when missclassify as class3 although actual class is 1, FPerror=1
My idea is when predicted class is not equal w actual class there is a possibility of missclassification.So, I want to count how many occurences/FPerror of pred_class=2,act_class=1, then pred_class=3,act_class=1
*repeats for each class w different combinations of predicted class and actual class
[n_act,lablist_act]=classsizes(E(loc:m,2));
[n_pred,lablist_pred]=classsizes(E(loc:m,3));
FPerror = 0;
for k=1:f % for each class
disp('FPcost = ');disp(n_act(k));
for p = 1 : f-1 % each possibility;if 3class possibility=2
for z = loc : m % for each interval
tf2 = isequal(E(z,2),E(z,3));
if (tf2 == 0) % pred not same w actual
tf3 = isequal(E(z,3),lablist_act(k));
tf4 = isequal(E(z,2),k);
if ((tf3 == 0) && (tf4 == 1))
FPerror = FPerror + 1;
end % end tf3 tf4
else % pred same w actual
FPerror = 0;
end %end tf2
end % end z loc m
disp('FPerror = ');disp(FPerror);
FPerror = 0; % clear value
end % end p f-1
end %for each class
Thank you.

Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!