/usr/include/dlib/statistics/lda_abstract.h is in libdlib-dev 18.18-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | // Copyright (C) 2014 Davis E. King (davis@dlib.net)
// License: Boost Software License See LICENSE.txt for the full license.
#undef DLIB_LDA_ABSTRACT_Hh_
#ifdef DLIB_LDA_ABSTRACT_Hh_
#include <map>
#include "../matrix.h"
#include <vector>
namespace dlib
{
// ----------------------------------------------------------------------------------------
template <
typename T
>
void compute_lda_transform (
matrix<T>& X,
matrix<T,0,1>& M,
const std::vector<unsigned long>& row_labels,
unsigned long lda_dims = 500,
unsigned long extra_pca_dims = 200
);
/*!
requires
- X.size() != 0
- row_labels.size() == X.nr()
- The number of distinct values in row_labels > 1
- lda_dims != 0
ensures
- We interpret X as a collection X.nr() of input vectors, where each row of X
is one of the vectors.
- We interpret row_labels[i] as the label of the vector rowm(X,i).
- This function performs the dimensionality reducing version of linear
discriminant analysis. That is, you give it a set of labeled vectors and it
returns a linear transform that maps the input vectors into a new space that
is good for distinguishing between the different classes. In particular,
this function finds matrices Z and M such that:
- Given an input vector x, Z*x-M, is the transformed version of x. That is,
Z*x-M maps x into a space where x vectors that share the same class label
are near each other.
- Z*x-M results in the transformed vectors having zero expected mean.
- Z.nr() <= lda_dims
(it might be less than lda_dims if there are not enough distinct class
labels to support lda_dims dimensions).
- Z.nc() == X.nc()
- We overwrite the input matrix X and store Z in it. Therefore, the
outputs of this function are in X and M.
- In order to deal with very high dimensional inputs, we perform PCA internally
to map the input vectors into a space of at most lda_dims+extra_pca_dims
prior to performing LDA.
!*/
// ----------------------------------------------------------------------------------------
std::pair<double,double> equal_error_rate (
const std::vector<double>& low_vals,
const std::vector<double>& high_vals
);
/*!
ensures
- This function finds a threshold T that best separates the elements of
low_vals from high_vals by selecting the threshold with equal error rate. In
particular, we try to pick a threshold T such that:
- for all valid i:
- high_vals[i] >= T
- for all valid i:
- low_vals[i] < T
Where the best T is determined such that the fraction of low_vals >= T is the
same as the fraction of high_vals < T.
- Let ERR == the equal error rate. I.e. the fraction of times low_vals >= T
and high_vals < T. Note that 0 <= ERR <= 1.
- returns make_pair(ERR,T)
!*/
// ----------------------------------------------------------------------------------------
}
#endif // DLIB_LDA_ABSTRACT_Hh_
|