Inconsistant Accuracy , Precision , Recall and F1 Score

9 次查看(过去 30 天)
Hi there,
I'm attempting to calculate Precision, Recall, and F1 score, but I see NaN in my calculations. Could you please assist me in resolving a computation bug?
Thank you
act =[
0
0.0269
0.0354
0
51.9578
34.4936
10.0596
4.2331
3.4373
2.0611
2.9576
3.1177
1.9092
1.8423
5.5713
4.7685
3.8489
3.8223
52.2738
26.4217];
pred = -0 + (100+0)*rand(size(act,1),1); %between a = 0 to b = 100
[m,order] = confusionmat(act,pred);
cmtx = m';
diagonal = diag(cmtx); % Bug here
SumOfrows = sum(cmtx,2);
precision = diagonal ./ SumOfrows;
OverallPrecision = mean(precision);
SumOfCol = sum(cmtx,1);
recall = diagonal ./ SumOfCol';
OverallRecall = mean(recall);
f1Score = 2* ((OverallPrecision*OverallRecall)/ OverallPrecision+OverallRecall);
precision,
precision = 39×1
NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
OverallPrecision,
OverallPrecision = NaN
recall,
recall = 39×1
0 0 0 0 0 0 0 0 0 0
OverallRecall,
OverallRecall = NaN
f1Score
f1Score = NaN
  20 个评论
dpb
dpb 2023-6-23
编辑:dpb 2023-6-23
Well, that's certainly a different result; those two have almost perfect correlation.
However, as to what can be inferred from the above and what sort of an analysis to apply is far too complex a question to answer in this forum; would need in-depth consultation in order to have a sufficient understanding of the problem in order to be able to do so.
Good luck in finding someone in your environment that has such expertise...
Life is Wonderful
Life is Wonderful 2023-6-24
Thank you very much for your time and efforts in helping me.
best wishes

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Descriptive Statistics 的更多信息

标签

产品


版本

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by