1#ifndef FSTCRITERIONNORMALGMAHALANOBIS_H
2#define FSTCRITERIONNORMALGMAHALANOBIS_H
106template<
class RETURNTYPE,
typename DATATYPE,
typename REALTYPE,
typename IDXTYPE,
typename DIMTYPE,
class SUBSET,
class DATAACCESSOR>
107class Criterion_Normal_GMahalanobis :
public Clonable_Impl<Criterion_Normal_GMahalanobis<RETURNTYPE,DATATYPE,REALTYPE,IDXTYPE,DIMTYPE,SUBSET,DATAACCESSOR>,Criterion_Normal<RETURNTYPE,DATATYPE,REALTYPE,IDXTYPE,DIMTYPE,SUBSET,DATAACCESSOR> > {
113 Criterion_Normal_GMahalanobis() {
notify(
"Criterion_Normal_GMahalanobis constructor.");}
119 virtual const char*
criterion_name()
const override {
return "Criterion_Normal_GMahalanobis";}
126 _cov12->set_all_raw_to(0.0);
134 Criterion_Normal_GMahalanobis(
const Criterion_Normal_GMahalanobis& cngm);
136 std::unique_ptr<Indexed_Matrix<DATATYPE,DIMTYPE,SUBSET> >
_cov12;
137 std::unique_ptr<Indexed_Matrix<REALTYPE,DIMTYPE,SUBSET> >
_invbuf;
138 std::unique_ptr<Indexed_Matrix<REALTYPE,DIMTYPE,SUBSET> >
_LUtemp;
141template<
class RETURNTYPE,
typename DATATYPE,
typename REALTYPE,
typename IDXTYPE,
typename DIMTYPE,
class SUBSET,
class DATAACCESSOR>
142Criterion_Normal_GMahalanobis<RETURNTYPE,DATATYPE,REALTYPE,IDXTYPE,DIMTYPE,SUBSET,DATAACCESSOR>::Criterion_Normal_GMahalanobis(
const Criterion_Normal_GMahalanobis& cngm) :
145 notify(
"Criterion_Normal_GMahalanobis copy-constructor.");
153template<
class RETURNTYPE,
typename DATATYPE,
typename REALTYPE,
typename IDXTYPE,
typename DIMTYPE,
class SUBSET,
class DATAACCESSOR>
156 notify(
"Criterion_Normal_GMahalanobis::evaluate_narrowed().");
CRTP mixin implementing the Clonable protocol for a concrete class.
Definition clonable.hpp:184
Implements Generalized Mahalanobis distance based on normal (gaussian) model to serve as feature sele...
Definition criterion_normal_gmahalanobis.hpp:107
virtual void allocate_buffers() override
(re)allocate criterion-specific work buffers for get_n() features (use the alloc_* helpers)
Definition criterion_normal_gmahalanobis.hpp:120
std::shared_ptr< DATAACCESSOR > PDataAccessor
shared pointer to the data accessor the model is learned from
Definition criterion_normal_gmahalanobis.hpp:111
std::unique_ptr< Indexed_Matrix< REALTYPE, DIMTYPE, SUBSET > > _LUtemp
scratch LU-decomposition storage, reused for each matrix inversion
Definition criterion_normal_gmahalanobis.hpp:138
std::unique_ptr< Indexed_Matrix< REALTYPE, DIMTYPE, SUBSET > > _invbuf
inverse of the narrowed _cov12, used in the quadratic-form term
Definition criterion_normal_gmahalanobis.hpp:137
virtual bool evaluate_narrowed(RETURNTYPE &result, const PSubset sub) override
narrow remaining buffers to sub, redim work buffers to get_d(), compute the criterion value....
Definition criterion_normal_gmahalanobis.hpp:154
std::unique_ptr< Indexed_Matrix< DATATYPE, DIMTYPE, SUBSET > > _cov12
prior-weighted pooled covariance Pc(0)*cov[0]+Pc(1)*cov[1], computed by update_derived_model()
Definition criterion_normal_gmahalanobis.hpp:136
std::shared_ptr< SUBSET > PSubset
shared pointer to the feature subset being evaluated
Definition criterion_normal_gmahalanobis.hpp:112
virtual const char * criterion_name() const override
class name, used in output and error messages
Definition criterion_normal_gmahalanobis.hpp:119
Criterion_Normal< RETURNTYPE, DATATYPE, REALTYPE, IDXTYPE, DIMTYPE, SUBSET, DATAACCESSOR > parent
base class: the normal-model template-method skeleton
Definition criterion_normal_gmahalanobis.hpp:109
Clonable_Impl< Criterion_Normal_GMahalanobis, parent > parent_impl
implements clone(); sharing/stateless_clone throw in Criterion
Definition criterion_normal_gmahalanobis.hpp:110
virtual void update_derived_model() override
Definition criterion_normal_gmahalanobis.hpp:125
Abstract class, defines interface for feature selection criterion implementations based on normal mod...
Definition criterion_normal.hpp:100
std::unique_ptr< Model_Normal< DATATYPE, REALTYPE, IDXTYPE, DIMTYPE, SUBSET, DATAACCESSOR > > _model
the learned per-class normal (mean/covariance) model, narrowed in evaluate()
Definition criterion_normal.hpp:149
void alloc_matrix(std::unique_ptr< Indexed_Matrix< MATRIXVALUETYPE, DIMTYPE, SUBSET > > &m, const bool LUstorage=false)
lazy (re)allocation of a work matrix for get_n() features; LUstorage as required by Indexed_Matrix::L...
Definition criterion_normal.hpp:144
DIMTYPE get_n() const
the full (raw, unnarrowed) feature count the model was learned for
Definition criterion_normal.hpp:119
std::unique_ptr< Indexed_Vector< DATATYPE, DIMTYPE, SUBSET > > _meandif
mean[0]-mean[1], shared by all two-class normal criteria
Definition criterion_normal.hpp:150
DIMTYPE get_d() const
the currently active (narrowed) feature count, see evaluate()
Definition criterion_normal.hpp:120
Matrix representation and operations, allows operation in selected subspace.
Definition indexed_matrix.hpp:102
Defines interface for feature selection criterion implementations based on normal model.
FST4 specific error passing class.
Matrix representation and operations, allows operation in selected subspace.
Vector representation and operations, allows operation in selected subspace.
The Feature Selection Toolbox 4 library: every library component – data access, criteria and classifi...
Definition data_accessor.hpp:80
void notify(const std::string msg)
Prints msg followed by a newline via syncout::print(); a no-op unless the preprocessor macro DEBUG is...
Definition global.hpp:112