test/machine_learning: fix positive and negative counting
authorInki Dae <inki.dae@samsung.com>
Mon, 30 May 2022 00:47:08 +0000 (09:47 +0900)
committerInki Dae <inki.dae@samsung.com>
Wed, 20 Jul 2022 05:16:57 +0000 (14:16 +0900)
[Issue type] bug fix

Fixed positive and negative counting.

Change-Id: I4689fc496e3fa36c118163cd498c838c023a92c9
Signed-off-by: Inki Dae <inki.dae@samsung.com>
test/testsuites/machine_learning/face_recognition/measure_face_recognition.cpp

index 4220173238cd15bb72ed5b2a2334d7aceece3ec0..f6cbce28987f5a05603bf99b8ee044fdc8f634ba 100644 (file)
@@ -88,7 +88,7 @@ TEST(FaceRecognitionAccuracy, Measure)
                ++train_cnt;
 
                // Train only images for classes defined with MAX_TRAINING_CLASS.
-               if (train_cnt == MAX_TRAINING_CLASS * SHOT_PER_CLASS - 1)
+               if (train_cnt == MAX_TRAINING_CLASS * SHOT_PER_CLASS)
                        break;
        }
 
@@ -102,8 +102,10 @@ TEST(FaceRecognitionAccuracy, Measure)
        }
 
        unsigned int test_cnt = 0;
-       unsigned int positive_cnt = 0;
-       unsigned int negative_cnt = 0;
+       unsigned int true_positive_cnt = 0;
+       unsigned int total_positive_cnt = 0;
+       unsigned int true_negative_cnt = 0;
+       unsigned int total_negative_cnt = 0;
 
        while (!test_file.eof()) {
                string filename, label, index;
@@ -131,11 +133,15 @@ TEST(FaceRecognitionAccuracy, Measure)
 
                auto it = find(cached_label.begin(), cached_label.end(), label);
                if (it != cached_label.end()) {
-                        if (label == string(result.label))
-                               positive_cnt++;
+                       total_positive_cnt++;
+
+                       if (label == string(result.label))
+                               true_positive_cnt++;
                } else {
+                       total_negative_cnt++;
+
                        if (ret == MEDIA_VISION_ERROR_NO_DATA)
-                               negative_cnt++;
+                               true_negative_cnt++;
                }
 
                ret = mv_destroy_source(mv_source);
@@ -146,10 +152,10 @@ TEST(FaceRecognitionAccuracy, Measure)
 
        cout << "Positive test" << endl;
        cout << "-------------" << endl;
-       cout << "correct answer = " << positive_cnt++ << " / " << test_cnt / 2 << endl << endl;
+       cout << "correct answer = " << true_positive_cnt << " / " << total_positive_cnt << endl << endl;
        cout << "Negative test" << endl;
        cout << "-------------" << endl;
-       cout << "correct answer = " << negative_cnt++ << " / " << test_cnt / 2 << endl;
+       cout << "correct answer = " << true_negative_cnt << " / " << total_negative_cnt << endl;
 
        ret = mv_face_recognition_destroy(handle);
        ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);