May 2020
Intermediate to advanced
530 pages
17h 8m
English
Using the linear algebra facilities of the Dlib library (or any other library, for that matter), we can implement anomaly detection with the multivariate Gaussian distribution approach. The following example shows how to implement this approach with the Dlib linear algebra routines:
void multivariateGaussianDist(const Matrix& normal, const Matrix& test) { // assume that rows are samples and columns are features // calculate per feature mean dlib::matrix<double> mu(1, normal.nc()); dlib::set_all_elements(mu, 0); for (long c = 0; c < normal.nc(); ++c) { auto col_mean = dlib::mean(dlib::colm(normal, c)); dlib::set_colm(mu, c) = col_mean; } // calculate covariance matrix dlib::matrix<double> cov(normal.nc(), ...Read now
Unlock full access