Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
BIAS::LDA Class Reference

linear discriminant analysis on a set of classes of vectors LDA is a approach for dimension-reduction of vector-classes while keeping class-separability More...

#include <MathAlgo/LDA.hh>

+ Inheritance diagram for BIAS::LDA:
+ Collaboration diagram for BIAS::LDA:

Public Member Functions

void AddDebugLevel (const long int lv)
 
void AddDebugLevel (const std::string &name)
 
void AnalyzeData (const std::vector< std::vector< BIAS::Vector< LDAType > > > &vec)
 Ouput statistical-data of input-data. More...
 
void ComputeAnonymousReduction (const std::vector< std::vector< BIAS::Vector< LDAType > > > &vec, BIAS::Matrix< LDAType > &matrix, int reductionSize=-1, const std::vector< std::vector< BIAS::Matrix< LDAType > > > *covs=NULL)
 Computes a reduction-matrix for features of n sets (e.g. More...
 
void ComputeMeans (const std::vector< std::vector< BIAS::Vector< LDAType > > > &vec)
 get mean of input get results with methods down under More...
 
void ComputeReductionMatrix (const std::vector< std::vector< BIAS::Vector< LDAType > > > &vec, BIAS::Matrix< LDAType > &matrix, int reductionSize=-1, std::vector< BIAS::Matrix< LDAType > > *covs=NULL)
 Computes a reduction-matrix the first dimension of the matrix is taken out of the first vector. More...
 
void ComputeReductionMatrix (BIAS::Matrix< LDAType > &classCov, BIAS::Matrix< LDAType > &cov, BIAS::Matrix< LDAType > &matrix, int reductionSize)
 computes reduction, given average within class cov and inter-class cov matrix More...
 
void ComputeWithinAndInterClassCovs (const std::vector< BIAS::Vector< LDAType > > &classmeans, const std::vector< BIAS::Matrix< LDAType > > &covs, BIAS::Matrix< LDAType > &withinClassCov, BIAS::Matrix< LDAType > &interClassCov)
 given mean and scatter of each class, compute scatter between class means and average class shape More...
 
bool DebugLevelIsSet (const long int lv) const
 
bool DebugLevelIsSet (const std::string &name) const
 
void GenerateRandomTestData (int vectorSize, int numberOfClasses, int classSizeMin, int classSizeMax, int vectorEntryMin, int vectorEntryMax, double stdDeviation, double mainDirectionStdDeviation, std::vector< std::vector< BIAS::Vector< LDAType > > > &vec, std::vector< BIAS::Vector< LDAType > > &means, bool Normalize)
 Generates random classes of vectors. More...
 
void GetClassMeans (std::vector< BIAS::Vector< LDAType > > &means)
 get mean vector for each class ComputeReductionMatrix or ComputeMeans has to be called first More...
 
int GetDebugLevel () const
 
std::ostream & GetDebugStream () const
 
void GetDebugStream (std::ostream &os) const
 
void GetMean (BIAS::Vector< LDAType > &mean)
 get a mean vector of all vectors ComputeReductionMatrix or ComputeMeans has to be called first More...
 
 LDA (bool equalClassWeights=true)
 
long int Name2DebugLevel (const std::string &name) const
 looks up a debuglevel in the internal map, returns 0 if not found More...
 
long int NewDebugLevel (const std::string &name)
 creates a new debuglevel More...
 
void PrintDebugLevel (std::ostream &os=std::cout) const
 
void RemoveDebugLevel (const long int lv)
 
void RemoveDebugLevel (const std::string &name)
 
void SetDebugLevel (const long int lv)
 
void SetDebugLevel (const std::string &name)
 
void SetDebugStream (const std::ostream &os)
 
void SetReductionSize (int size)
 reduction size can be set here More...
 
void ShowDebugLevel (std::ostream &os=std::cout) const
 prints all internally known debuglevels More...
 

Static Public Member Functions

static long int GetGlobalDebugLevel ()
 
static void SetGlobalDebugLevel (long int lev)
 

Protected Member Functions

long ConsumeNextFreeDebuglevel_ ()
 returns the next available debuglevel More...
 

Protected Attributes

long int _liDebugLevel
 
long int _liNextDebugLevel
 new concept, debuglevel are managed here in the debug class More...
 
std::map< std::string, long int > _String2Debuglevel
 
int allCount_
 
std::vector< BIAS::Vector
< LDAType > > 
classMeans_
 mean vector for each class More...
 
bool equalClassWeights_
 
BIAS::Vector< LDAType > mean_
 mean of all vectors More...
 
int reductionSize_
 reduction size More...
 

Static Protected Attributes

static std::ostream _zDebugStream
 
static long int GlobalDebugLevel = 0
 

Detailed Description

linear discriminant analysis on a set of classes of vectors LDA is a approach for dimension-reduction of vector-classes while keeping class-separability

Author
haertel 01/06
Examples:
ExampleLDA.cpp.

Definition at line 46 of file LDA.hh.

Constructor & Destructor Documentation

BIAS::LDA::LDA ( bool  equalClassWeights = true)
inline

Definition at line 50 of file LDA.hh.

Member Function Documentation

void BIAS::Debug::AddDebugLevel ( const long int  lv)
inlineinherited
void BIAS::Debug::AddDebugLevel ( const std::string &  name)
inlineinherited

Definition at line 362 of file Debug.hh.

void LDA::AnalyzeData ( const std::vector< std::vector< BIAS::Vector< LDAType > > > &  vec)

Ouput statistical-data of input-data.

Parameters
vecthe input data

Definition at line 48 of file LDA.cpp.

References TNT::Vector< T >::newsize(), BIAS::Matrix< T >::SetZero(), and TNT::Vector< T >::size().

void LDA::ComputeAnonymousReduction ( const std::vector< std::vector< BIAS::Vector< LDAType > > > &  vec,
BIAS::Matrix< LDAType > &  matrix,
int  reductionSize = -1,
const std::vector< std::vector< BIAS::Matrix< LDAType > > > *  covs = NULL 
)

Computes a reduction-matrix for features of n sets (e.g.

n images), whose class relations (correspondence) are anonymous

Parameters
vecthe input: a vector (one entry for each image) of vectors of features
matrixthe matrix returned
reductionSizethe second dimension of the matrix
covsvector of covs for each feature in vec

Definition at line 562 of file LDA.cpp.

References BIAS::PCA::ComputeMean(), BIAS::PCA::ComputeScatter(), BIAS::MatrixZero, BIAS::Vector< T >::Size(), and TNT::Vector< T >::size().

void LDA::ComputeMeans ( const std::vector< std::vector< BIAS::Vector< LDAType > > > &  vec)

get mean of input get results with methods down under

Definition at line 502 of file LDA.cpp.

References TNT::Vector< T >::size().

void LDA::ComputeReductionMatrix ( const std::vector< std::vector< BIAS::Vector< LDAType > > > &  vec,
BIAS::Matrix< LDAType > &  matrix,
int  reductionSize = -1,
std::vector< BIAS::Matrix< LDAType > > *  covs = NULL 
)

Computes a reduction-matrix the first dimension of the matrix is taken out of the first vector.

Parameters
vecthe input: a vector of classes of vectors
matrixthe matrix returned
reductionSizethe second dimension of the matrix
covspass vector of correct size to retrieve class covs, leave zero size vector to save memory and destroy covs after usage
Examples:
ExampleLDA.cpp.

Definition at line 269 of file LDA.cpp.

References BIAS::FileHandling::CurrentDateTimeString(), BIAS::MatrixZero, BIAS::Matrix< T >::SetZero(), and TNT::Vector< T >::size().

void LDA::ComputeReductionMatrix ( BIAS::Matrix< LDAType > &  classCov,
BIAS::Matrix< LDAType > &  cov,
BIAS::Matrix< LDAType > &  matrix,
int  reductionSize 
)
void LDA::ComputeWithinAndInterClassCovs ( const std::vector< BIAS::Vector< LDAType > > &  classmeans,
const std::vector< BIAS::Matrix< LDAType > > &  covs,
BIAS::Matrix< LDAType > &  withinClassCov,
BIAS::Matrix< LDAType > &  interClassCov 
)

given mean and scatter of each class, compute scatter between class means and average class shape

Definition at line 538 of file LDA.cpp.

References BIAS::PCA::ComputeMean(), BIAS::PCA::ComputeScatter(), BIAS::Matrix< T >::NormFrobenius(), TNT::Matrix< T >::num_cols(), and TNT::Matrix< T >::num_rows().

long BIAS::Debug::ConsumeNextFreeDebuglevel_ ( )
inlineprotectedinherited

returns the next available debuglevel

Author
woelk 09/2006

Definition at line 521 of file Debug.hh.

bool BIAS::Debug::DebugLevelIsSet ( const long int  lv) const
inlineinherited
bool BIAS::Debug::DebugLevelIsSet ( const std::string &  name) const
inlineinherited

Definition at line 350 of file Debug.hh.

void LDA::GenerateRandomTestData ( int  vectorSize,
int  numberOfClasses,
int  classSizeMin,
int  classSizeMax,
int  vectorEntryMin,
int  vectorEntryMax,
double  stdDeviation,
double  mainDirectionStdDeviation,
std::vector< std::vector< BIAS::Vector< LDAType > > > &  vec,
std::vector< BIAS::Vector< LDAType > > &  means,
bool  Normalize 
)

Generates random classes of vectors.

Parameters
vectorSizedimensionality
numberOfClasseshow many classes should be generated (number of mean-vectors)
classSizeMinhow many vectors should at least be in every class
classSizeMaxhow many vectors should at most be in every class
vectorEntryMinthe min-value of every vectors component
vectorEntryMaxthe max-value of every vectors component
stdDeviationStandard-Deviation of how a vector is distributed around it's class mean
mainDirectionStdDeviationStandard-Deviation of the same main-direction of all classes
vecreturns a vector of classes, every class is a vector of vectors
meansreturns the original mean-vectors used for each class-generation
Normalizeshould descriptors be normalized?

Definition at line 132 of file LDA.cpp.

References BIAS::SVD::Compute(), BIAS::Random::GetNormalDistributed(), BIAS::Matrix< T >::GetRow(), BIAS::SVD::GetS(), BIAS::SVD::GetU(), BIAS::Random::GetUniformDistributed(), BIAS::Random::GetUniformDistributedInt(), BIAS::SVD::GetVT(), TNT::Matrix< T >::newsize(), BIAS::Matrix< T >::NormL2(), BIAS::Random::Reset(), and BIAS::Matrix< T >::SetZero().

void LDA::GetClassMeans ( std::vector< BIAS::Vector< LDAType > > &  means)

get mean vector for each class ComputeReductionMatrix or ComputeMeans has to be called first

Definition at line 529 of file LDA.cpp.

int BIAS::Debug::GetDebugLevel ( ) const
inlineinherited
std::ostream& BIAS::Debug::GetDebugStream ( ) const
inlineinherited

Definition at line 405 of file Debug.hh.

void BIAS::Debug::GetDebugStream ( std::ostream &  os) const
inlineinherited

Definition at line 414 of file Debug.hh.

static long int BIAS::Debug::GetGlobalDebugLevel ( )
inlinestaticinherited

Definition at line 431 of file Debug.hh.

void LDA::GetMean ( BIAS::Vector< LDAType > &  mean)

get a mean vector of all vectors ComputeReductionMatrix or ComputeMeans has to be called first

Definition at line 525 of file LDA.cpp.

long int BIAS::Debug::Name2DebugLevel ( const std::string &  name) const
inlineinherited

looks up a debuglevel in the internal map, returns 0 if not found

Author
woelk 09/2006

Definition at line 454 of file Debug.hh.

long int BIAS::Debug::NewDebugLevel ( const std::string &  name)
inlineinherited
void BIAS::Debug::PrintDebugLevel ( std::ostream &  os = std::cout) const
inlineinherited

Definition at line 383 of file Debug.hh.

void BIAS::Debug::RemoveDebugLevel ( const long int  lv)
inlineinherited

Definition at line 369 of file Debug.hh.

void BIAS::Debug::RemoveDebugLevel ( const std::string &  name)
inlineinherited

Definition at line 376 of file Debug.hh.

void BIAS::Debug::SetDebugLevel ( const long int  lv)
inlineinherited
void BIAS::Debug::SetDebugLevel ( const std::string &  name)
inlineinherited

Definition at line 325 of file Debug.hh.

void BIAS::Debug::SetDebugStream ( const std::ostream &  os)
inlineinherited

Definition at line 398 of file Debug.hh.

static void BIAS::Debug::SetGlobalDebugLevel ( long int  lev)
inlinestaticinherited

Definition at line 424 of file Debug.hh.

void LDA::SetReductionSize ( int  size)

reduction size can be set here

Definition at line 533 of file LDA.cpp.

void BIAS::Debug::ShowDebugLevel ( std::ostream &  os = std::cout) const
inlineinherited

prints all internally known debuglevels

Author
woelk 09/2006

Definition at line 496 of file Debug.hh.

Member Data Documentation

long int BIAS::Debug::_liDebugLevel
protectedinherited

Definition at line 510 of file Debug.hh.

Referenced by BIAS::Debug::operator=(), and BIAS::ImageBase::operator=().

long int BIAS::Debug::_liNextDebugLevel
protectedinherited

new concept, debuglevel are managed here in the debug class

Definition at line 516 of file Debug.hh.

Referenced by BIAS::Debug::operator=().

std::map<std::string, long int> BIAS::Debug::_String2Debuglevel
protectedinherited

Definition at line 517 of file Debug.hh.

Referenced by BIAS::Debug::operator=().

std::ostream BIAS::Debug::_zDebugStream
staticprotectedinherited

Definition at line 511 of file Debug.hh.

Referenced by BIAS::Debug::operator=().

int BIAS::LDA::allCount_
protected

Definition at line 155 of file LDA.hh.

std::vector<BIAS::Vector<LDAType> > BIAS::LDA::classMeans_
protected

mean vector for each class

Definition at line 150 of file LDA.hh.

bool BIAS::LDA::equalClassWeights_
protected

Definition at line 156 of file LDA.hh.

long int BIAS::Debug::GlobalDebugLevel = 0
staticprotectedinherited

Definition at line 513 of file Debug.hh.

BIAS::Vector<LDAType> BIAS::LDA::mean_
protected

mean of all vectors

Definition at line 152 of file LDA.hh.

int BIAS::LDA::reductionSize_
protected

reduction size

Definition at line 154 of file LDA.hh.


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