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

abstract class, defines interface for Regressor implementations (mainly to be used in wrappers) More...

#include <regressor.hpp>

Inheritance diagram for FST::Regressor< RETURNTYPE, DIMTYPE, SUBSET, DATAACCESSOR >:
FST::Clonable FST::Clonable_Impl< Regressor_Ridge< RETURNTYPE, DATATYPE, REALTYPE, IDXTYPE, DIMTYPE, SUBSET, DATAACCESSOR >, Regressor< RETURNTYPE, DIMTYPE, SUBSET, DATAACCESSOR > > FST::Clonable_Impl< Regressor_Weighted_Neighbours< RETURNTYPE, DATATYPE, IDXTYPE, DIMTYPE, SUBSET, DATAACCESSOR, DISTANCE >, Regressor< RETURNTYPE, DIMTYPE, SUBSET, DATAACCESSOR > > FST::Regressor_Ridge< RETURNTYPE, DATATYPE, REALTYPE, IDXTYPE, DIMTYPE, SUBSET, DATAACCESSOR > FST::Regressor_Weighted_Neighbours< RETURNTYPE, DATATYPE, IDXTYPE, DIMTYPE, SUBSET, DATAACCESSOR, DISTANCE >

Public Types

typedef std::shared_ptr< DATAACCESSOR > PDataAccessor
 shared pointer to the data accessor supplying train/test blocks
typedef std::shared_ptr< SUBSET > const PSubset
 shared pointer to the (fixed, non-reassignable) feature subset being evaluated
typedef DATAACCESSOR::PPattern PPattern
 one data sample as exposed by DATAACCESSOR (a raw pointer to its feature vector)

Public Member Functions

virtual bool predict (RETURNTYPE &depvar, const PPattern &pattern)=0
 Predicts the dependent variable of one pattern into depvar (see the dependent-variable convention in the class documentation). Returns false when no prediction can be made at all - the regressor has not been trained, or the implementation hit an unrecoverable condition; false aborts the enclosing test loop.
virtual bool train (const PDataAccessor da, const PSubset sub)=0
virtual bool test (RETURNTYPE &result, const PDataAccessor da)=0
 Scores the designated test data with the regressor's own default measure, oriented higher-is-better (a hit rate under the class-label convention, a negated prediction error otherwise). Returns false if the test part is empty or predict() failed.
virtual bool test_metric (RETURNTYPE &result, const PDataAccessor da, const Metric_Spec< RETURNTYPE > &spec)
Regressor * clone () const override=0
Regressor * sharing_clone () const override
Regressor * 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
virtual std::ostream & print (std::ostream &os) const
 writes a human-readable identification of the object; base default writes nothing

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 DATAACCESSOR>
class FST::Regressor< RETURNTYPE, DIMTYPE, SUBSET, DATAACCESSOR >

abstract class, defines interface for Regressor implementations (mainly to be used in wrappers)

The counterpart of Classifier for the regression pipeline; the same lifecycle applies - train() first, then test*()/predict(), with a data accessor exposing the same features in the same order. Two regressors are shipped: Regressor_Weighted_Neighbours (distance-weighted nearest neighbours) and Regressor_Ridge (closed-form L2-regularized least squares).

Note
DEPENDENT-VARIABLE CONVENTION. The dependent variable predicted here is by default the CLASS LABEL of the sample, not a data column - "regression simulating classification", which is what makes a regressor usable as a feature-selection criterion on ordinary classification data. Concrete regressors express this with the sentinel index -1 (set_dependent_index(-1)), their default; a non-negative index selects an actual data column instead.
Every value produced for a criterion is oriented HIGHER IS BETTER, as FST4 searches maximize: test() returns a hit rate under the class-label convention and a NEGATED error otherwise, and the regression metrics of the metric palette are r2, neg-rmse and neg-mae (see Metric_Spec).

Member Function Documentation

◆ clone()

template<class RETURNTYPE, typename DIMTYPE, class SUBSET, class DATAACCESSOR>
Regressor * FST::Regressor< RETURNTYPE, DIMTYPE, SUBSET, DATAACCESSOR >::clone ( ) const
overridepure virtual

◆ predict()

template<class RETURNTYPE, typename DIMTYPE, class SUBSET, class DATAACCESSOR>
virtual bool FST::Regressor< RETURNTYPE, DIMTYPE, SUBSET, DATAACCESSOR >::predict ( RETURNTYPE & depvar,
const PPattern & pattern )
pure virtual

Predicts the dependent variable of one pattern into depvar (see the dependent-variable convention in the class documentation). Returns false when no prediction can be made at all - the regressor has not been trained, or the implementation hit an unrecoverable condition; false aborts the enclosing test loop.

Implemented in FST::Regressor_Ridge< RETURNTYPE, DATATYPE, REALTYPE, IDXTYPE, DIMTYPE, SUBSET, DATAACCESSOR >, and FST::Regressor_Weighted_Neighbours< RETURNTYPE, DATATYPE, IDXTYPE, DIMTYPE, SUBSET, DATAACCESSOR, DISTANCE >.

◆ sharing_clone()

template<class RETURNTYPE, typename DIMTYPE, class SUBSET, class DATAACCESSOR>
Regressor * FST::Regressor< RETURNTYPE, DIMTYPE, SUBSET, DATAACCESSOR >::sharing_clone ( ) const
inlineoverridevirtual

create equivalent clone of the current object, permitting read-only access to structures in the source object (allows referencing instead of copying of large memory structures). may be faster and save space but requires more caution with respect to concurrency Use example: Data_Accessor memory data representation cloning

Implements FST::Clonable.

◆ stateless_clone()

template<class RETURNTYPE, typename DIMTYPE, class SUBSET, class DATAACCESSOR>
Regressor * FST::Regressor< RETURNTYPE, DIMTYPE, SUBSET, DATAACCESSOR >::stateless_clone ( ) const
inlineoverridevirtual

create clone of the current object, ignoring internal temporary structures to save speed. Does not replicate exact object state. The clone must be used carefully in a way that ensures internal structure re-initialization Use example: Data_Splitter cloning or Classifier_LIBSVM cloning due to inability to clone external structures defined in LibSVM

Implements FST::Clonable.

◆ test()

template<class RETURNTYPE, typename DIMTYPE, class SUBSET, class DATAACCESSOR>
virtual bool FST::Regressor< RETURNTYPE, DIMTYPE, SUBSET, DATAACCESSOR >::test ( RETURNTYPE & result,
const PDataAccessor da )
pure virtual

Scores the designated test data with the regressor's own default measure, oriented higher-is-better (a hit rate under the class-label convention, a negated prediction error otherwise). Returns false if the test part is empty or predict() failed.

Implemented in FST::Regressor_Ridge< RETURNTYPE, DATATYPE, REALTYPE, IDXTYPE, DIMTYPE, SUBSET, DATAACCESSOR >, and FST::Regressor_Weighted_Neighbours< RETURNTYPE, DATATYPE, IDXTYPE, DIMTYPE, SUBSET, DATAACCESSOR, DISTANCE >.

◆ test_metric()

template<class RETURNTYPE, typename DIMTYPE, class SUBSET, class DATAACCESSOR>
virtual bool FST::Regressor< RETURNTYPE, DIMTYPE, SUBSET, DATAACCESSOR >::test_metric ( RETURNTYPE & result,
const PDataAccessor da,
const Metric_Spec< RETURNTYPE > & spec )
inlinevirtual

evaluates the designated test data under the given regression metric (r2/neg-rmse/neg-mae); the default spec is served by test() itself. Classification metrics do not apply to a regression stack and make this return false. The dependent-variable convention is the concrete regressor's - see the class documentation.

Reimplemented in FST::Regressor_Ridge< RETURNTYPE, DATATYPE, REALTYPE, IDXTYPE, DIMTYPE, SUBSET, DATAACCESSOR >, and FST::Regressor_Weighted_Neighbours< RETURNTYPE, DATATYPE, IDXTYPE, DIMTYPE, SUBSET, DATAACCESSOR, DISTANCE >.

◆ train()

template<class RETURNTYPE, typename DIMTYPE, class SUBSET, class DATAACCESSOR>
virtual bool FST::Regressor< RETURNTYPE, DIMTYPE, SUBSET, DATAACCESSOR >::train ( const PDataAccessor da,
const PSubset sub )
pure virtual

learns from designated training part of data


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.