| 278 | |
| 279 | } |
| 280 | END_SECTION |
| 281 | |
| 282 | START_SECTION(regression_train_and_predict_on_separate) |
| 283 | { |
| 284 | // Same data as above but with split out test data (inlier + outlier) |
| 285 | |
| 286 | SimpleSVM::PredictorMap x{ {"x", { |
| 287 | 0.0827345, 0.0860808, 0.1587253, |
| 288 | 0.2340380, 0.2376890, 0.2420991, 0.3825909, |
| 289 | 0.4185480, 0.4909027, 0.9507514, |
| 290 | 0.9566240, 1.0680931, 1.1448901, |
| 291 | 1.3127954, 1.6548730, 1.8522109, 1.9021369, |
| 292 | 2.0112177, 2.2142165, 2.2331448, |
| 293 | 2.7221007, 2.8684072, 2.9972565, 3.0146882, |
| 294 | 3.0934168, 3.2048384, 3.2171502, 3.2959385, |
| 295 | 3.6047516, 4.0592506, 4.0725104, |
| 296 | 4.7699635, 4.8069954, 4.8126888 }}}; |
| 297 | |
| 298 | map<Size, double> y{ { |
| 299 | {0, 0.0826401}, {1, 0.0859745}, {2, 0.1580597}, {3, 0.2319073}, {4, 1.1990320}, |
| 300 | {5, 0.2397410}, {6, 0.3733253}, {7, 0.4064343}, {8, 0.4714222}, {9, 0.8138523}, |
| 301 | {10, 0.8172507}, {11, 0.8762834}, {12, 0.9106647}, {13, 0.9669019}, {14, 0.9964676}, |
| 302 | {15, 0.9606635}, {16, 0.9456070}, {17, 1.3416947}, {18, 0.8000485}, {19, 0.7885501}, |
| 303 | {20, 0.4072964}, {21, -0.1396564}, {22, 0.1438354}, {23, 0.1265640}, {24, 0.0481571}, {25, -0.0632036}, |
| 304 | {26, -0.2082548}, {27, -0.1537337}, {28, -0.4467765}, {29, -0.7941806}, {30, -0.8021682}, |
| 305 | {31, -0.9983430}, {32, -0.9955281}, {33, -0.9949741 } } }; |
| 306 | |
| 307 | SimpleSVM::PredictorMap x_test{ {"x", { |
| 308 | 0.0604460, |
| 309 | 0.7375445, |
| 310 | 1.2531016, |
| 311 | 2.3437173, |
| 312 | 4.1267237, |
| 313 | 4.7097008 }}}; |
| 314 | |
| 315 | map<Size, double> y_test{ { |
| 316 | {0, -0.0604637}, |
| 317 | {1, 2.1056848}, |
| 318 | {2, 1.4817945}, |
| 319 | {3, 0.7158742}, |
| 320 | {4, -1.9997169}, |
| 321 | {5, -0.9999963} } }; |
| 322 | |
| 323 | auto param = svm.getParameters(); |
| 324 | param.setValue("kernel", "RBF"); |
| 325 | param.setValue("log2_C", ListUtils::create<double>("1,5")); |
| 326 | param.setValue("log2_gamma", ListUtils::create<double>("-5,5")); |
| 327 | param.setValue("log2_p", ListUtils::create<double>("-15,-3.32192809489")); |
| 328 | svm.setParameters(param); |
| 329 | |
| 330 | svm.setParameters(param); |
| 331 | |
| 332 | svm.setup(x, y, false); // set up regression |
| 333 | |
| 334 | vector<SimpleSVM::Prediction> predictions; |
| 335 | svm.predict(x_test, predictions); |
| 336 | |
| 337 | // test a few inlier |
nothing calls this directly
no test coverage detected