| 700 | } |
| 701 | |
| 702 | void test_average_precision() |
| 703 | { |
| 704 | std::vector<bool> items; |
| 705 | DLIB_TEST(average_precision(items) == 1); |
| 706 | DLIB_TEST(average_precision(items,1) == 0); |
| 707 | |
| 708 | items.push_back(true); |
| 709 | DLIB_TEST(average_precision(items) == 1); |
| 710 | DLIB_TEST(std::abs(average_precision(items,1) - 0.5) < 1e-14); |
| 711 | |
| 712 | items.push_back(true); |
| 713 | DLIB_TEST(average_precision(items) == 1); |
| 714 | DLIB_TEST(std::abs(average_precision(items,1) - 2.0/3.0) < 1e-14); |
| 715 | |
| 716 | items.push_back(false); |
| 717 | |
| 718 | DLIB_TEST(average_precision(items) == 1); |
| 719 | DLIB_TEST(std::abs(average_precision(items,1) - 2.0/3.0) < 1e-14); |
| 720 | |
| 721 | items.push_back(true); |
| 722 | |
| 723 | DLIB_TEST(std::abs(average_precision(items) - (2.0+3.0/4.0)/3.0) < 1e-14); |
| 724 | |
| 725 | items.push_back(true); |
| 726 | |
| 727 | DLIB_TEST(std::abs(average_precision(items) - (2.0 + 4.0/5.0 + 4.0/5.0)/4.0) < 1e-14); |
| 728 | DLIB_TEST(std::abs(average_precision(items,1) - (2.0 + 4.0/5.0 + 4.0/5.0)/5.0) < 1e-14); |
| 729 | } |
| 730 | |
| 731 | |
| 732 | template <typename sample_type> |
nothing calls this directly
no test coverage detected