Abstract class, defines interface for feature selection criterion implementations based on normal model.
More...
|
| virtual bool | initialize (PDataAccessor da) |
| | template method: learn model, compute _meandif, then allocate_buffers() + update_derived_model().
|
| virtual bool | evaluate (RETURNTYPE &result, const PSubset sub) override |
| | template method: narrow model and _meandif to sub, then evaluate_narrowed()
|
| virtual bool | is_monotonic () const override |
|
DIMTYPE | get_n () const |
| | the full (raw, unnarrowed) feature count the model was learned for
|
|
DIMTYPE | get_d () const |
| | the currently active (narrowed) feature count, see evaluate()
|
| virtual std::ostream & | print (std::ostream &os) const override |
| | writes a human-readable identification of the object; base default writes nothing
|
| Criterion * | clone () const override=0 |
| Criterion * | sharing_clone () const override |
| Criterion * | stateless_clone () const override |
| bool | is_clone () const |
|
bool | is_sharing () const |
| | true if this instance is a sharing_clone() result (referencing, not owning, the source's structures)
|
|
bool | is_sharing_clone () const |
| | true if this instance is BOTH a clone and sharing – i.e. specifically a sharing_clone() result, not a clone()/stateless_clone() one
|
|
|
| Criterion_Normal (const Criterion_Normal &cn) |
| | Copy-constructor; deep-copies _model and _meandif (subclasses copy their own buffers separately).
|
| virtual const char * | criterion_name () const =0 |
| | class name, used in output and error messages
|
| virtual void | allocate_buffers ()=0 |
| | (re)allocate criterion-specific work buffers for get_n() features (use the alloc_* helpers)
|
| virtual void | update_derived_model ()=0 |
| 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. On entry _model and _meandif have ALREADY been narrowed to sub by evaluate(), so the implementation sees only the d selected features; get_d() is that d, and _meandif->at(i) addresses the narrowed positions. sub is non-empty (evaluate() rejects d==0 before the call).
|
|
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()
|
|
template<typename MATRIXVALUETYPE> |
| 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::LUdecompose() temp storage
|
|
void | set_cloned (const bool cloned=true) |
| | marks/unmarks this instance as a clone; call from clone()/stateless_clone() overrides (Clonable_Impl does this automatically)
|
|
void | set_sharing (const bool sharing=true) |
| | marks/unmarks this instance as sharing (see is_sharing())
|
|
void | set_sharing_cloned (const bool cloned=true, const bool sharing=true) |
| | sets both flags at once; call from sharing_clone() overrides (Clonable_Impl does this automatically)
|
template<class RETURNTYPE, typename DATATYPE, typename REALTYPE, typename IDXTYPE, typename DIMTYPE, class SUBSET, class DATAACCESSOR>
class FST::Criterion_Normal< RETURNTYPE, DATATYPE, REALTYPE, IDXTYPE, DIMTYPE, SUBSET, DATAACCESSOR >
Abstract class, defines interface for feature selection criterion implementations based on normal model.
- Note
- This class also provides the template-method skeleton shared by the concrete two-class normal criteria (Bhattacharyya, Divergence, GMahalanobis): initialize() learns the model, allocates buffers and computes the shared mean-difference vector before delegating criterion-specific pre-computation to hooks; evaluate() narrows the model and delegates the math to evaluate_narrowed(). Subclasses keep only their buffers, their pre-computation and their math.
-
All these criteria are defined for TWO-CLASS data only - initialize() throws fst_error when the data accessor reports a different number of classes.
template<class RETURNTYPE, typename DATATYPE, typename REALTYPE, typename IDXTYPE, typename DIMTYPE, class SUBSET, class DATAACCESSOR>
| virtual void FST::Criterion_Normal< RETURNTYPE, DATATYPE, REALTYPE, IDXTYPE, DIMTYPE, SUBSET, DATAACCESSOR >::allocate_buffers |
( |
| ) |
|
|
protectedpure virtual |
(re)allocate criterion-specific work buffers for get_n() features (use the alloc_* helpers)
Implemented in FST::Criterion_Normal_Bhattacharyya< RETURNTYPE, DATATYPE, REALTYPE, IDXTYPE, DIMTYPE, SUBSET, DATAACCESSOR >, FST::Criterion_Normal_Divergence< RETURNTYPE, DATATYPE, REALTYPE, IDXTYPE, DIMTYPE, SUBSET, DATAACCESSOR >, and FST::Criterion_Normal_GMahalanobis< RETURNTYPE, DATATYPE, REALTYPE, IDXTYPE, DIMTYPE, SUBSET, DATAACCESSOR >.
template<class RETURNTYPE, typename DATATYPE, typename REALTYPE, typename IDXTYPE, typename DIMTYPE, class SUBSET, class DATAACCESSOR>
| virtual const char * FST::Criterion_Normal< RETURNTYPE, DATATYPE, REALTYPE, IDXTYPE, DIMTYPE, SUBSET, DATAACCESSOR >::criterion_name |
( |
| ) |
const |
|
protectedpure virtual |
class name, used in output and error messages
Implemented in FST::Criterion_Normal_Bhattacharyya< RETURNTYPE, DATATYPE, REALTYPE, IDXTYPE, DIMTYPE, SUBSET, DATAACCESSOR >, FST::Criterion_Normal_Divergence< RETURNTYPE, DATATYPE, REALTYPE, IDXTYPE, DIMTYPE, SUBSET, DATAACCESSOR >, and FST::Criterion_Normal_GMahalanobis< RETURNTYPE, DATATYPE, REALTYPE, IDXTYPE, DIMTYPE, SUBSET, DATAACCESSOR >.
template<class RETURNTYPE, typename DATATYPE, typename REALTYPE, typename IDXTYPE, typename DIMTYPE, class SUBSET, class DATAACCESSOR>
| bool FST::Criterion_Normal< RETURNTYPE, DATATYPE, REALTYPE, IDXTYPE, DIMTYPE, SUBSET, DATAACCESSOR >::evaluate |
( |
RETURNTYPE & | result, |
|
|
const PSubset | sub ) |
|
overridevirtual |
template<class RETURNTYPE, typename DATATYPE, typename REALTYPE, typename IDXTYPE, typename DIMTYPE, class SUBSET, class DATAACCESSOR>
| virtual bool FST::Criterion_Normal< RETURNTYPE, DATATYPE, REALTYPE, IDXTYPE, DIMTYPE, SUBSET, DATAACCESSOR >::evaluate_narrowed |
( |
RETURNTYPE & | result, |
|
|
const PSubset | sub ) |
|
protectedpure virtual |
narrow remaining buffers to sub, redim work buffers to get_d(), compute the criterion value. On entry _model and _meandif have ALREADY been narrowed to sub by evaluate(), so the implementation sees only the d selected features; get_d() is that d, and _meandif->at(i) addresses the narrowed positions. sub is non-empty (evaluate() rejects d==0 before the call).
Implemented in FST::Criterion_Normal_Bhattacharyya< RETURNTYPE, DATATYPE, REALTYPE, IDXTYPE, DIMTYPE, SUBSET, DATAACCESSOR >, FST::Criterion_Normal_Divergence< RETURNTYPE, DATATYPE, REALTYPE, IDXTYPE, DIMTYPE, SUBSET, DATAACCESSOR >, and FST::Criterion_Normal_GMahalanobis< RETURNTYPE, DATATYPE, REALTYPE, IDXTYPE, DIMTYPE, SUBSET, DATAACCESSOR >.
template<class RETURNTYPE, typename DATATYPE, typename REALTYPE, typename IDXTYPE, typename DIMTYPE, class SUBSET, class DATAACCESSOR>
template method: learn model, compute _meandif, then allocate_buffers() + update_derived_model().
- Exceptions
-
| fst_error | if da does not describe exactly 2 classes. |
- Returns
- true (failures are reported by throwing)
template<class RETURNTYPE, typename DATATYPE, typename REALTYPE, typename IDXTYPE, typename DIMTYPE, class SUBSET, class DATAACCESSOR>
| virtual bool FST::Criterion_Normal< RETURNTYPE, DATATYPE, REALTYPE, IDXTYPE, DIMTYPE, SUBSET, DATAACCESSOR >::is_monotonic |
( |
| ) |
const |
|
inlineoverridevirtual |
all three normal-model filters (Bhattacharyya, Generalized Mahalanobis, Divergence) are monotonic w.r.t. subset cardinality, hence B&B-compatible; Divergence holds the property in theory only - see the numerical-instability known issue (prefer Bhattacharyya for B&B)
Reimplemented from FST::Criterion< RETURNTYPE, SUBSET >.
template<class RETURNTYPE, typename DATATYPE, typename REALTYPE, typename IDXTYPE, typename DIMTYPE, class SUBSET, class DATAACCESSOR>
| virtual std::ostream & FST::Criterion_Normal< RETURNTYPE, DATATYPE, REALTYPE, IDXTYPE, DIMTYPE, SUBSET, DATAACCESSOR >::print |
( |
std::ostream & | os | ) |
const |
|
inlineoverridevirtual |
writes a human-readable identification of the object; base default writes nothing
Reimplemented from FST::Clonable.
template<class RETURNTYPE, typename DATATYPE, typename REALTYPE, typename IDXTYPE, typename DIMTYPE, class SUBSET, class DATAACCESSOR>
| virtual void FST::Criterion_Normal< RETURNTYPE, DATATYPE, REALTYPE, IDXTYPE, DIMTYPE, SUBSET, DATAACCESSOR >::update_derived_model |
( |
| ) |
|
|
protectedpure virtual |
precompute criterion-specific derivations of the freshly learned model (_meandif is already computed)
Implemented in FST::Criterion_Normal_Bhattacharyya< RETURNTYPE, DATATYPE, REALTYPE, IDXTYPE, DIMTYPE, SUBSET, DATAACCESSOR >, FST::Criterion_Normal_Divergence< RETURNTYPE, DATATYPE, REALTYPE, IDXTYPE, DIMTYPE, SUBSET, DATAACCESSOR >, and FST::Criterion_Normal_GMahalanobis< RETURNTYPE, DATATYPE, REALTYPE, IDXTYPE, DIMTYPE, SUBSET, DATAACCESSOR >.