May 2020
Intermediate to advanced
530 pages
17h 8m
English
The Dlib library provides the krr_trainer class, which can get the template argument of the linear_kernel type to solve linear regression tasks. This class implements direct analytical solving for this type of problem with the kernel ridge regression algorithm, as illustrated in the following code block:
std::vector<matrix<double>> x;std::vector<float> y;krr_trainer<KernelType> trainer;trainer.set_kernel(KernelType());decision_function<KernelType> df = trainer.train(x, y);
For new x inputs, we can predict new y values in the following way:
std::vector<matrix<double>> new_x;for (auto& v : x) { auto prediction = df(v); std::cout << prediction << std::endl;}
Read now
Unlock full access