May 2020
Intermediate to advanced
530 pages
17h 8m
English
The Dlib library also contains all the necessary functionality for the grid search algorithm. However, we should use functions instead of classes. The following code snippet shows the CrossValidationScore function's definition. This function performs cross-validation and returns the value of the performance metric:
auto CrossValidationScore = [&](const double gamma, const double c, const double degree_in) { auto degree = std::floor(degree_in); using KernelType = Dlib::polynomial_kernel<SampleType>; Dlib::svr_trainer<KernelType> trainer; trainer.set_kernel(KernelType(gamma, c, degree)); Dlib::matrix<double> result = Dlib::cross_validate_regression_trainer( trainer, samples, raw_labels, 10); return result(0, 0);};
The CrossValidationScore ...
Read now
Unlock full access