"""Computes a linear discriminant analysis (LDA) on the given data, possibly after computing a principal component analysis (PCA).
This algorithm computes a LDA projection (:py:class:`bob.learn.linear.FisherLDATrainer`) on the given training features, projects the features to Fisher space and computes the distance of two projected features in Fisher space.
For example, the Fisher faces algorithm as proposed by [ZKC+98]_ can be run with this class.
Additionally, a PCA projection matrix can be computed beforehand, to reduce the dimensionality of the input vectors.
In that case, the finally stored projection matrix is the combination of the PCA and LDA projection.
**Parameters:**
lda_subspace_dimension : int or ``None``
If specified, the LDA subspace will be truncated to the given number of dimensions.
By default (``None``) it is limited to the number of classes in the training set - 1.
pca_subspace_dimentsion : int or float or ``None``
If specified, a combined PCA + LDA projection matrix will be computed.
If specified as ``int``, defines the number of eigenvectors used in the PCA projection matrix.
If specified as ``float`` (between 0 and 1), the number of eigenvectors is calculated such that the given percentage of variance is kept.
use_pinv : bool
Use the Pseudo-inverse to compute the LDA projection matrix?
Sometimes, the training fails because it is impossible to invert the covariance matrix.
In these cases, you might want to set ``use_pinv`` to ``True``, which solves this process, but slows down the processing noticeably.
distance_function : function
A function taking two parameters and returns a float.
If ``uses_variances`` is set to ``True``, the function is provided with a third parameter, which is the vector of variances (aka. eigenvalues).
is_distance_function : bool
Set this flag to ``False`` if the given ``distance_function`` computes a similarity value (i.e., higher values are better)
use_variances : bool
If set to ``True``, the ``distance_function`` is provided with a third argument, which is the vector of variances (aka. eigenvalues).
kwargs : ``key=value`` pairs
A list of keyword arguments directly passed to the :py:class:`Algorithm` base class constructor.
"""
def__init__(
self,
lda_subspace_dimension=None,# if set, the LDA subspace will be truncated to the given number of dimensions; by default it is limited to the number of classes in the training set
pca_subspace_dimension=None,# if set, a PCA subspace truncation is performed before applying LDA; might be integral or float