Feature Selection Toolbox FST4
UTIA · Czech Academy of Sciences
Loading...
Searching...
No Matches
FST::Criterion_Sum_Of_Weights< RETURNTYPE, DIMTYPE, SUBSET > Class Template Reference

Returns sum of pre-specified feature weights for features in the evaluated subset. More...

#include <criterion_sumofweights.hpp>

Inheritance diagram for FST::Criterion_Sum_Of_Weights< RETURNTYPE, DIMTYPE, SUBSET >:
FST::Clonable_Impl< Criterion_Sum_Of_Weights< RETURNTYPE, DIMTYPE, SUBSET >, Criterion< RETURNTYPE, SUBSET > > FST::Criterion< RETURNTYPE, SUBSET > FST::Clonable

Public Types

typedef Clonable_Impl< Criterion_Sum_Of_Weights, Criterion< RETURNTYPE, SUBSET > > parent_impl
 implements clone(); sharing/stateless_clone throw in Criterion
typedef std::shared_ptr< SUBSET > PSubset
 shared pointer to the feature subset being evaluated
typedef std::shared_ptr< RETURNTYPE > PWeights
 shared pointer to a raw array of noofweights per-feature weights
Public Types inherited from FST::Criterion< RETURNTYPE, SUBSET >
typedef std::shared_ptr< SUBSET > PSubset
 shared pointer to the feature subset being evaluated

Public Member Functions

virtual void initialize (const DIMTYPE noofweights, const PWeights weights)
 Adopts an existing weight array: SHARES ownership with the caller, nothing is copied.
virtual void initialize (const DIMTYPE noofweights, const RETURNTYPE weights[])
 Copies noofweights weights from a raw array into a freshly owned buffer (the caller's array is not referenced afterwards); see the ownership warning above.
virtual bool evaluate (RETURNTYPE &result, const PSubset sub) override
 Sums up the weights of the features selected in sub; always returns true. Weights are indexed by RAW feature index, so the array must hold exactly one entry per feature of the full feature set (asserted: noofweights == sub->get_n()).
virtual std::ostream & print (std::ostream &os) const override
 writes a human-readable identification of the object; base default writes nothing
Public Member Functions inherited from FST::Clonable_Impl< Criterion_Sum_Of_Weights< RETURNTYPE, DIMTYPE, SUBSET >, Criterion< RETURNTYPE, SUBSET > >
Criterion< RETURNTYPE, SUBSET > * clone () const override
 dispatches to the DEEP_KIND mechanism (default CLONE_DEEP: Derived's copy-constructor)
Criterion< RETURNTYPE, SUBSET > * sharing_clone () const override
 dispatches to the SHARING_KIND mechanism (default CLONE_INHERIT: defers to Base, which throws by family convention)
Criterion< RETURNTYPE, SUBSET > * stateless_clone () const override
 dispatches to the STATELESS_KIND mechanism (default CLONE_INHERIT: defers to Base, which throws by family convention)
Public Member Functions inherited from FST::Criterion< RETURNTYPE, SUBSET >
virtual bool is_monotonic () const
Criterion * sharing_clone () const override
Criterion * stateless_clone () const override
Public Member Functions inherited from FST::Clonable
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

Protected Attributes

PWeights _weights
 per-feature weights, indexed by raw feature index (size _noofweights)
DIMTYPE _noofweights
 number of entries in _weights; must equal the evaluated subset's get_n()

Private Member Functions

 Criterion_Sum_Of_Weights (const Criterion_Sum_Of_Weights &css)
 Copy-constructor; deep-copies the weight array into a freshly owned buffer.

Private Attributes

friend parent_impl

Additional Inherited Members

Protected Member Functions inherited from FST::Clonable
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)

Detailed Description

template<class RETURNTYPE, typename DIMTYPE, class SUBSET>
class FST::Criterion_Sum_Of_Weights< RETURNTYPE, DIMTYPE, SUBSET >

Returns sum of pre-specified feature weights for features in the evaluated subset.

This trivial criterion is intended as secondary criterion to be used in conjunction with Result_Tracker_Regularizer, allowing to find subset among those close to the known best such that the sum of known feature weights (e.g., feature acquisition cost) is minimized. This is usable, e.g., in medicine where different measurements have different costs (e.g., measuring body temperature may be cheaper than laboratory tests, etc.). The technique is described in paper "Somol, Grim, Pudil: The Problem of Fragile Feature Subset Preference in Feature Selection Methods and A Proposal of Algorithmic Workaround. In Proc. ICPR 2010. IEEE Computer Society, 2010".

Member Function Documentation

◆ evaluate()

template<class RETURNTYPE, typename DIMTYPE, class SUBSET>
bool FST::Criterion_Sum_Of_Weights< RETURNTYPE, DIMTYPE, SUBSET >::evaluate ( RETURNTYPE & result,
const PSubset sub )
overridevirtual

Sums up the weights of the features selected in sub; always returns true. Weights are indexed by RAW feature index, so the array must hold exactly one entry per feature of the full feature set (asserted: noofweights == sub->get_n()).

Implements FST::Criterion< RETURNTYPE, SUBSET >.

◆ initialize()

template<class RETURNTYPE, typename DIMTYPE, class SUBSET>
virtual void FST::Criterion_Sum_Of_Weights< RETURNTYPE, DIMTYPE, SUBSET >::initialize ( const DIMTYPE noofweights,
const PWeights weights )
inlinevirtual

Adopts an existing weight array: SHARES ownership with the caller, nothing is copied.

Warning
The two initialize() overloads differ in ownership. This one keeps the caller's buffer alive through the shared_ptr and lets the caller keep modifying it; the array[] overload below takes a private copy instead. Note that clones always deep-copy, so a cloned criterion stops sharing the array whichever overload was used.

◆ print()

template<class RETURNTYPE, typename DIMTYPE, class SUBSET>
virtual std::ostream & FST::Criterion_Sum_Of_Weights< RETURNTYPE, DIMTYPE, SUBSET >::print ( std::ostream & os) const
inlineoverridevirtual

writes a human-readable identification of the object; base default writes nothing

Reimplemented from FST::Clonable.

Member Data Documentation

◆ parent_impl

template<class RETURNTYPE, typename DIMTYPE, class SUBSET>
friend FST::Criterion_Sum_Of_Weights< RETURNTYPE, DIMTYPE, SUBSET >::parent_impl
private

grants Clonable_Impl access to the copy-constructor


The documentation for this class was generated from the following file:
Copyright © 2000–present ÚTIA, Institute of Information Theory and Automation of the Czech Academy of Sciences · Contacts · This site sets no cookies and uses no analytics.