改写以下代码,使其计算准确率时分别将误报计算为非有效诊断:accTest1 = sum(testYreal_out==1 & testYreal==1)/sum(testYreal==1); accTest2 = sum(testYreal_out==2 & testYreal==2)/sum(testYreal==2); accTest3 = sum(testYreal_out==3 & testYreal==3)/sum(testYreal==3); accTest4 = sum(testYreal_out==4 & testYreal==4)/sum(testYreal==4);
时间: 2023-09-30 08:12:29 浏览: 63
以下是将误报计算为非有效诊断的改写代码:
total_diagnosis_1 = sum(testYreal==1)
correct_diagnosis_1 = sum(testYreal_out==1 & testYreal==1)
false_positives_1 = sum(testYreal_out==1 & testYreal~=1)
total_diagnosis_2 = sum(testYreal==2)
correct_diagnosis_2 = sum(testYreal_out==2 & testYreal==2)
false_positives_2 = sum(testYreal_out==2 & testYreal~=2)
total_diagnosis_3 = sum(testYreal==3)
correct_diagnosis_3 = sum(testYreal_out==3 & testYreal==3)
false_positives_3 = sum(testYreal_out==3 & testYreal~=3)
total_diagnosis_4 = sum(testYreal==4)
correct_diagnosis_4 = sum(testYreal_out==4 & testYreal==4)
false_positives_4 = sum(testYreal_out==4 & testYreal~=4)
accTest1 = correct_diagnosis_1 / (total_diagnosis_1 - false_positives_1)
accTest2 = correct_diagnosis_2 / (total_diagnosis_2 - false_positives_2)
accTest3 = correct_diagnosis_3 / (total_diagnosis_3 - false_positives_3)
accTest4 = correct_diagnosis_4 / (total_diagnosis_4 - false_positives_4)
accuracy = (correct_diagnosis_1 + correct_diagnosis_2 + correct_diagnosis_3 + correct_diagnosis_4) / (total_diagnosis_1 + total_diagnosis_2 + total_diagnosis_3 + total_diagnosis_4)
false_alarm_rate = (false_positives_1 + false_positives_2 + false_positives_3 + false_positives_4) / (sum(testYreal~=1) + sum(testYreal~=2) + sum(testYreal~=3) + sum(testYreal~=4))
阅读全文