#include <regressors.hpp>
Public Member Functions | |
cv::Mat | solve (cv::Mat data, cv::Mat labels, Regulariser regulariser) |
A solver that the LinearRegressor uses to solve its system of linear equations. It needs a solve function with the following signature: cv::Mat
solve(cv::Mat data, cv::Mat labels, Regulariser regulariser)
The PartialPivLUSolver
is a fast solver but it can't check for invertibility. It supports parallel solving if compiled with OpenMP enabled. Uses PartialPivLU::solve() instead of inverting the matrix.
|
inline |
Solves the linear system \( (\text{data}^\text{T} * \text{data} + \text{regulariser}) * \text{X} = \text{data}^\text{T} * \text{labels}\) where regulariser is a diagonal matrix. This results in a least-squares approximation of the original system. labels
can consist of multiple columns.
Note/Todo: we should leave the choice of inverting A or AtA to the solver. But this also means we need to pass through the regularisation params. We can't just pass a cv::Mat regularisation because the dimensions for regularising A and AtA are different.
[in] | data | Data matrix with each row being a data sample. |
[in] | labels | Labels for each data sample. |
[in] | regulariser | A regularisation. |