Linear Discriminant Analysis (LDA) More...
#include <shark/Algorithms/Trainers/LDA.h>
Public Member Functions | |
LDA (double regularization=0.0) | |
constructor More... | |
std::string | name () const |
From INameable: return the class name. More... | |
double | regularization () const |
return the regularization constant More... | |
void | setRegularization (double regularization) |
set the regularization constant. 0 means no regularization. More... | |
RealVector | parameterVector () const |
inherited from IParameterizable; read the regularization parameter More... | |
void | setParameterVector (RealVector const ¶m) |
inherited from IParameterizable; set the regularization parameter More... | |
size_t | numberOfParameters () const |
inherited from IParameterizable More... | |
SHARK_EXPORT_SYMBOL void | train (LinearClassifier<> &model, LabeledData< RealVector, unsigned int > const &dataset) |
Compute the LDA solution for a multi-class problem. More... | |
SHARK_EXPORT_SYMBOL void | train (LinearClassifier<> &model, WeightedLabeledData< RealVector, unsigned int > const &dataset) |
Compute the LDA solution for a weighted multi-class problem. More... | |
Public Member Functions inherited from shark::AbstractWeightedTrainer< LinearClassifier<>, unsigned int > | |
virtual void | train (ModelType &model, WeightedDatasetType const &dataset)=0 |
Executes the algorithm and trains a model on the given weighted data. More... | |
virtual void | train (ModelType &model, DatasetType const &dataset) |
Executes the algorithm and trains a model on the given unweighted data. More... | |
Public Member Functions inherited from shark::INameable | |
virtual | ~INameable () |
Public Member Functions inherited from shark::ISerializable | |
virtual | ~ISerializable () |
Virtual d'tor. More... | |
virtual void | read (InArchive &archive) |
Read the component from the supplied archive. More... | |
virtual void | write (OutArchive &archive) const |
Write the component to the supplied archive. More... | |
void | load (InArchive &archive, unsigned int version) |
Versioned loading of components, calls read(...). More... | |
void | save (OutArchive &archive, unsigned int version) const |
Versioned storing of components, calls write(...). More... | |
BOOST_SERIALIZATION_SPLIT_MEMBER () | |
Public Member Functions inherited from shark::IParameterizable<> | |
virtual | ~IParameterizable () |
Protected Attributes | |
double | m_regularization |
Additional Inherited Members | |
Public Types inherited from shark::AbstractWeightedTrainer< LinearClassifier<>, unsigned int > | |
typedef base_type::ModelType | ModelType |
typedef base_type::InputType | InputType |
typedef base_type::LabelType | LabelType |
typedef base_type::DatasetType | DatasetType |
typedef WeightedLabeledData< InputType, LabelType > | WeightedDatasetType |
Public Types inherited from shark::AbstractTrainer< LinearClassifier<>, unsigned int > | |
typedef LinearClassifier<> | ModelType |
typedef ModelType::InputType | InputType |
typedef unsigned int | LabelType |
typedef LabeledData< InputType, LabelType > | DatasetType |
Public Types inherited from shark::IParameterizable<> | |
typedef RealVector | ParameterVectorType |
Linear Discriminant Analysis (LDA)
This classes implements the well known linear discriminant analysis. LDA assumes that every point is drawn from a multivariate normal distributions. Every class has its own mean but all classes have the same covariance.
An arbitrary number of classes is supported. The resulting model is of the form
\[ \arg \max_c \log(p(x|c)*P(c)) \]
where \( p(x|c) = \exp(-(x-m_c)^T(C+\alpha I)(x-m_c)) \). \( m_c\) are the means of class c, \( C \) is the covariance matrix formed by all data points. The regularization paramter \( \alpha \) is by default 0. The trainer is implemented such, that it still works when C is singular, in this case the singular directions are ignored.
|
inline |
constructor
Definition at line 62 of file LDA.h.
References regularization(), and setRegularization().
|
inlinevirtual |
From INameable: return the class name.
Reimplemented from shark::INameable.
Definition at line 67 of file LDA.h.
Referenced by main().
|
inlinevirtual |
inherited from IParameterizable
Reimplemented from shark::IParameterizable<>.
Definition at line 93 of file LDA.h.
References SHARK_EXPORT_SYMBOL, and train().
|
inlinevirtual |
inherited from IParameterizable; read the regularization parameter
Reimplemented from shark::IParameterizable<>.
Definition at line 82 of file LDA.h.
References m_regularization.
|
inline |
return the regularization constant
Definition at line 71 of file LDA.h.
References m_regularization.
Referenced by LDA(), and setRegularization().
|
inlinevirtual |
inherited from IParameterizable; set the regularization parameter
Reimplemented from shark::IParameterizable<>.
Definition at line 88 of file LDA.h.
References m_regularization, and SIZE_CHECK.
|
inline |
set the regularization constant. 0 means no regularization.
Definition at line 76 of file LDA.h.
References m_regularization, RANGE_CHECK, and regularization().
Referenced by LDA().
SHARK_EXPORT_SYMBOL void shark::LDA::train | ( | LinearClassifier<> & | model, |
LabeledData< RealVector, unsigned int > const & | dataset | ||
) |
Compute the LDA solution for a multi-class problem.
Referenced by main(), and numberOfParameters().
SHARK_EXPORT_SYMBOL void shark::LDA::train | ( | LinearClassifier<> & | model, |
WeightedLabeledData< RealVector, unsigned int > const & | dataset | ||
) |
Compute the LDA solution for a weighted multi-class problem.
|
protected |
The regularization parameter \( \lambda \) adds \( - \lambda I \) to the second moment matrix, where \( I \) is the identity matrix
Definition at line 106 of file LDA.h.
Referenced by parameterVector(), regularization(), setParameterVector(), and setRegularization().