LTI-Lib latest version v1.9 - last update 10 Apr 2010

lti::linearDiscriminantAnalysis< T > Class Template Reference
[LAPack based functors]

Functor for computing a linear discriminant analysis (LDA). More...

#include <ltiLDA.h>

Inheritance diagram for lti::linearDiscriminantAnalysis< T >:
Inheritance graph
[legend]
Collaboration diagram for lti::linearDiscriminantAnalysis< T >:
Collaboration graph
[legend]

List of all members.

Classes

class  parameters
 the parameters for the class linearDiscriminantAnalysis More...

Public Member Functions

 linearDiscriminantAnalysis ()
 linearDiscriminantAnalysis (const linearDiscriminantAnalysis &other)
virtual ~linearDiscriminantAnalysis ()
virtual const char * getTypeName () const
bool apply (matrix< T > &srcdest, const ivector &labels)
bool apply (const matrix< T > &src, matrix< T > &dest, const ivector &labels)
bool apply (const matrix< T > &src, matrix< T > &dest, const matrix< T > &Sb)
bool apply (const matrix< T > &src, matrix< T > &result)
bool apply (const vector< T > &src, vector< T > &result)
bool apply (matrix< T > &srcdest)
void setDimension (int k)
virtual bool setParameters (const parameters &theParam)
bool getEigenValues (vector< T > &result) const
const vector< T > & getEigenValues () const
bool getEigenVectors (matrix< T > &result) const
bool getEigenVectorsInRows (matrix< T > &result) const
linearDiscriminantAnalysiscopy (const linearDiscriminantAnalysis &other)
virtual functorclone () const
const parametersgetParameters () const
bool computeSb (const matrix< T > &src, matrix< T > &Sb, const ivector &labels) const
virtual bool read (ioHandler &handler, const bool complete=true)
virtual bool write (ioHandler &handler, const bool complete=true) const

Protected Member Functions

int checkDim ()

Detailed Description

template<class T>
class lti::linearDiscriminantAnalysis< T >

Functor for computing a linear discriminant analysis (LDA).

It uses functors that require the LAPack.

See also:
LAPack based functors

Constructor & Destructor Documentation

default constructor

template<class T >
lti::linearDiscriminantAnalysis< T >::linearDiscriminantAnalysis ( const linearDiscriminantAnalysis< T > &  other  ) 

copy constructor

Parameters:
other the object to be copied
template<class T >
virtual lti::linearDiscriminantAnalysis< T >::~linearDiscriminantAnalysis (  )  [virtual]

destructor


Member Function Documentation

template<class T >
bool lti::linearDiscriminantAnalysis< T >::apply ( matrix< T > &  srcdest  ) 

On-Place version of the transformation.

Parameters:
srcdest matrix<T> with the source data, which will also contain the result.
Returns:
true if the LDA could be applied, false otherwise
template<class T >
bool lti::linearDiscriminantAnalysis< T >::apply ( const vector< T > &  src,
vector< T > &  result 
)

Uses a previously computed transform in order to reduce the given data set's dimensionality according to the resultDim parameter.

Parameters:
src matrix<T> with the source data.
result matrix<T> with the result data.
Returns:
true if the LDA could be applied, false otherwise
template<class T >
bool lti::linearDiscriminantAnalysis< T >::apply ( const matrix< T > &  src,
matrix< T > &  result 
)

Uses a previously computed transform in order to reduce the given data set's dimensionality according to the resultDim parameter.

Parameters:
src matrix<T> with the source data.
result matrix<T> with the result data.
Returns:
true if the LDA could be applied, false otherwise
template<class T >
bool lti::linearDiscriminantAnalysis< T >::apply ( const matrix< T > &  src,
matrix< T > &  dest,
const matrix< T > &  Sb 
)

Computes a linear discriminant analysis for the data given in src.

This matrix is assumed to contain the data points for one class. The computed transformation is stored internally and can be used just as a global transformation. The main purpose of this method is to be used for LDA classifiers, which compute class-wise LDA transforms and classify by subsequently applying the LDA's of all classes to the vector, and then choosing the class whose mean is closest to the presented vector. This method can be used to compute the required LDAs.

Parameters:
src matrix<T> with the source data.
dest matrix<T> where the result will be left.
Sb matrix<T> which is the between-class scatter matrix of the entire population.
Returns:
true if the LDA could be computed, false otherwise
template<class T >
bool lti::linearDiscriminantAnalysis< T >::apply ( const matrix< T > &  src,
matrix< T > &  dest,
const ivector labels 
)

Computes the linear discriminant analysis for the data given in src.

It internally stores a transformation matrix which is applied to the data. This matrix can be reused by calling one of the functions without the label vector.

Parameters:
src matrix<T> with the source data.
dest matrix<T> where the result will be left.
labels ivector for each row of the source matrix, this vector contains the class label.
Returns:
true if the LDA could be computed, false otherwise
template<class T >
bool lti::linearDiscriminantAnalysis< T >::apply ( matrix< T > &  srcdest,
const ivector labels 
)

operates on the given parameter.

Parameters:
srcdest matrix<T> with the source data. The result will be left here too.
labels ivector for each row of the source matrix, this vector contains the class label.
Returns:
true if the LDA could be computed, false otherwise
template<class T >
int lti::linearDiscriminantAnalysis< T >::checkDim (  )  [protected]

Determines the intrinsic dimensionality of the data set if the user specify autoDim, otherwise return parameters::resultDim.

The member usedDimensionality will be set with the returned value

template<class T >
virtual functor* lti::linearDiscriminantAnalysis< T >::clone (  )  const [virtual]

returns a pointer to a clone of this functor.

Implements lti::functor.

template<class T >
bool lti::linearDiscriminantAnalysis< T >::computeSb ( const matrix< T > &  src,
matrix< T > &  Sb,
const ivector labels 
) const

Computes the between-class scatter matrix Sb.

template<class T >
linearDiscriminantAnalysis& lti::linearDiscriminantAnalysis< T >::copy ( const linearDiscriminantAnalysis< T > &  other  ) 

copy data of "other" functor.

Parameters:
other the functor to be copied
Returns:
a reference to this functor object

Reimplemented from lti::functor.

template<class T >
const vector<T>& lti::linearDiscriminantAnalysis< T >::getEigenValues (  )  const

Returns the previously computed eigenvalues of the scatter matrix.

Returns:
true if the values could be obtained, false otherwise.
template<class T >
bool lti::linearDiscriminantAnalysis< T >::getEigenValues ( vector< T > &  result  )  const

Returns the previously computed eigenvalues of the scatter matrix.

Parameters:
result the vector which will receive the eigenvalues.
Returns:
true if the values could be obtained, false otherwise.
template<class T >
bool lti::linearDiscriminantAnalysis< T >::getEigenVectors ( matrix< T > &  result  )  const

Returns the previously computed eigenvectors of the scatter matrix.

Parameters:
result the matrix which will receive the eigenvectors. Each column of the matrix contains one eigenvector.
Returns:
true if the vectors could be obtained, false otherwise
template<class T >
bool lti::linearDiscriminantAnalysis< T >::getEigenVectorsInRows ( matrix< T > &  result  )  const

Returns the previously computed eigenvectors of the scatter matrix.

This method will call the normal getEigenVectors() methods and after that will transpose the obtained matrix, i.e. it is faster to get the eigenvectors in the columns.

Parameters:
result the matrix which will receive the eigenvectors. Each row of the matrix contains one eigenvector.
Returns:
true if the vectors could be obtained, false otherwise
template<class T >
const parameters& lti::linearDiscriminantAnalysis< T >::getParameters (  )  const

returns used parameters

Reimplemented from lti::functor.

template<class T >
virtual const char* lti::linearDiscriminantAnalysis< T >::getTypeName (  )  const [virtual]

returns the name of this type ("linearDiscriminantAnalysis")

Reimplemented from lti::linearAlgebraFunctor.

template<class T >
virtual bool lti::linearDiscriminantAnalysis< T >::read ( ioHandler handler,
const bool  complete = true 
) [virtual]

Read the functor from the given ioHandler.

The default implementation is to read just the parameters object.

Since this virtual method needs to know the exact type of the parameters to call the proper read method, it will just assume that the current functor instance has a valid parameter set. If this is not the case, you need to reimplement the read method to set first a dummy parameter object.

Parameters:
handler the ioHandler to be used
complete if true (the default) the enclosing begin/end will be also written, otherwise only the data block will be written.
Returns:
true if write was successful

Reimplemented from lti::functor.

template<class T >
void lti::linearDiscriminantAnalysis< T >::setDimension ( int  k  ) 

Set the dimension to which the vectors should be reduced.

template<class T >
virtual bool lti::linearDiscriminantAnalysis< T >::setParameters ( const parameters theParam  )  [virtual]

set functor's parameters.

This member makes a copy of theParam: the functor will keep its own copy of the parameters! The difference to the standard is that this one passes the useSVD flag on to the matrix inverter.

Returns:
true if successful, false otherwise

Reimplemented from lti::functor.

template<class T >
virtual bool lti::linearDiscriminantAnalysis< T >::write ( ioHandler handler,
const bool  complete = true 
) const [virtual]

return the last message set with setStatusString().

This will never return 0. If no status-string has been set yet an empty string (pointer to a string with only the char(0)) will be returned. set a status string.

Parameters:
msg the const string to be reported next time by getStatusString(). The given string will be copied. This message will be usually set within the apply methods to indicate an error cause.

Note that the change of the status string is not considered as a change in the functor status. append a message to the current status string. Take care to reset the status string by calling setStatusString() for each call of an apply() or similar method. appendStatusString() should only be used after setStatusString() has been called.

Parameters:
msg message to be appended to the current status string.

Note that the change of the status string is not considered as a change in the functor status. append an integer value to the current status string. Take care to reset the status string by calling setStatusString() for each call of an apply() or similar method. appendStatusString() should only be used after setStatusString() has been called.

Parameters:
msg integer value to be appended to the current status string.

Note that the change of the status string is not considered as a change in the functor status. append a double value to the current status string. Take care to reset the status string by calling setStatusString() for each call of an apply() or similar method. appendStatusString() should only be used after setStatusString() has been called.

Parameters:
msg double value to be appended to the current status string.

Note that the change of the status string is not considered as a change in the functor status. Append the status string of another functor to this functors status string. To achieve better readability of the resulting message a new line is started with the other functor's name and the message.

Parameters:
other functor whose status string is to be append to this status string.

Note that the change of the status string is not considered as a change in the functor status. write the functor in the given ioHandler. The default implementation is to write just the parameters object.

Parameters:
handler the ioHandler to be used
complete if true (the default) the enclosing begin/end will be also written, otherwise only the data block will be written.
Returns:
true if write was successful

Reimplemented from lti::functor.


The documentation for this class was generated from the following file:

Generated on Sat Apr 10 15:29:15 2010 for LTI-Lib by Doxygen 1.6.1