| 26 | // a little. |
| 27 | template <typename sample_type> |
| 28 | void make_problem(std::vector<sample_type>& x, std::vector<double>& y, const int num_pos = 20) |
| 29 | { |
| 30 | dlib::rand rnd; |
| 31 | for (int i = 0; i < 100; ++i) |
| 32 | { |
| 33 | const double label = i < num_pos ? +1 : -1; |
| 34 | const double a = label + rnd.get_random_gaussian(); |
| 35 | const double b = rnd.get_random_gaussian(); |
| 36 | if constexpr (is_matrix<sample_type>::value) |
| 37 | x.push_back({a, b}); |
| 38 | else |
| 39 | x.push_back({{0, a}, {1, b}}); |
| 40 | y.push_back(label); |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | // Returns the power of 10 C, between 1e-6 and 1e6, with which a class-balanced |
| 45 | // svm_c_linear_dcd_trainer gives df, or 0 if none does. |
no test coverage detected