1#ifndef FSTCRITERIONNORMAL_H
2#define FSTCRITERIONNORMAL_H
99template<
class RETURNTYPE,
typename DATATYPE,
typename REALTYPE,
typename IDXTYPE,
typename DIMTYPE,
class SUBSET,
class DATAACCESSOR>
100class Criterion_Normal :
public Criterion_Filter<RETURNTYPE,SUBSET> {
105 virtual ~Criterion_Normal() {
notify(
"Criterion_Normal destructor.");}
143 template<
typename MATRIXVALUETYPE>
146 if(
get_n()>m->get_n()) m->reset(
get_n(),LUstorage);
149 std::unique_ptr<Model_Normal<DATATYPE,REALTYPE,IDXTYPE,DIMTYPE,SUBSET,DATAACCESSOR> >
_model;
150 std::unique_ptr<Indexed_Vector<DATATYPE,DIMTYPE,SUBSET> >
_meandif;
153template<
class RETURNTYPE,
typename DATATYPE,
typename REALTYPE,
typename IDXTYPE,
typename DIMTYPE,
class SUBSET,
class DATAACCESSOR>
154Criterion_Normal<RETURNTYPE,DATATYPE,REALTYPE,IDXTYPE,DIMTYPE,SUBSET,DATAACCESSOR>::Criterion_Normal(
const Criterion_Normal& cn)
156 notify(
"Criterion_Normal copy-constructor.");
161template<
class RETURNTYPE,
typename DATATYPE,
typename REALTYPE,
typename IDXTYPE,
typename DIMTYPE,
class SUBSET,
class DATAACCESSOR>
162Criterion_Normal<RETURNTYPE,DATATYPE,REALTYPE,IDXTYPE,DIMTYPE,SUBSET,DATAACCESSOR>::Criterion_Normal()
164 notify(
"Criterion_Normal constructor.");
168template<
class RETURNTYPE,
typename DATATYPE,
typename REALTYPE,
typename IDXTYPE,
typename DIMTYPE,
class SUBSET,
class DATAACCESSOR>
171 if(da->getNoOfClasses()!=2)
throw fst_error(std::string(
criterion_name())+
"() defined for two-class problems only.");
172 notify(
"Criterion_Normal::initialize().");
185template<
class RETURNTYPE,
typename DATATYPE,
typename REALTYPE,
typename IDXTYPE,
typename DIMTYPE,
class SUBSET,
class DATAACCESSOR>
188 notify(
"Criterion_Normal::evaluate().");
195 if(sub->get_d_raw()==0)
return false;
204 if(!std::isfinite(result))
205 throw FST::fst_error(std::string(
criterion_name())+
"::evaluate: non-finite criterion value on the evaluated subset (numerically singular class covariance; reduce the subset size, drop constant or collinear features, or use more training data)");
Abstract class, defines interface for feature selection criterion implementations based on normal mod...
Definition criterion_normal.hpp:100
virtual void update_derived_model()=0
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
virtual const char * criterion_name() const =0
class name, used in output and error messages
DIMTYPE get_n() const
the full (raw, unnarrowed) feature count the model was learned for
Definition criterion_normal.hpp:119
virtual bool evaluate_narrowed(RETURNTYPE &result, const PSubset sub)=0
narrow remaining buffers to sub, redim work buffers to get_d(), compute the criterion value....
void alloc_vector(std::unique_ptr< Indexed_Vector< DATATYPE, DIMTYPE, SUBSET > > &v)
lazy (re)allocation of a work vector for get_n() features, for use from allocate_buffers()
Definition criterion_normal.hpp:138
std::shared_ptr< DATAACCESSOR > PDataAccessor
shared pointer to the data accessor the model is learned from
Definition criterion_normal.hpp:102
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
virtual bool initialize(PDataAccessor da)
template method: learn model, compute _meandif, then allocate_buffers() + update_derived_model().
Definition criterion_normal.hpp:169
std::shared_ptr< SUBSET > PSubset
shared pointer to the feature subset being evaluated
Definition criterion_normal.hpp:103
virtual std::ostream & print(std::ostream &os) const override
writes a human-readable identification of the object; base default writes nothing
Definition criterion_normal.hpp:122
virtual bool is_monotonic() const override
Definition criterion_normal.hpp:117
virtual bool evaluate(RETURNTYPE &result, const PSubset sub) override
template method: narrow model and _meandif to sub, then evaluate_narrowed()
Definition criterion_normal.hpp:186
virtual void allocate_buffers()=0
(re)allocate criterion-specific work buffers for get_n() features (use the alloc_* helpers)
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
Vector representation and operations, allows operation in selected subspace. Also serves as the helpe...
Definition indexed_vector.hpp:100
Implements normal (gaussian) model.
Definition model_normal.hpp:112
FST4 specific error passing class.
Definition error.hpp:61
Defines interface for feature selection criterion classes.
FST4 specific error passing class.
Matrix representation and operations, allows operation in selected subspace.
Vector representation and operations, allows operation in selected subspace.
Implements normal (gaussian) model.
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