Feature Selection Toolbox FST4
UTIA · Czech Academy of Sciences
Loading...
Searching...
No Matches
regressor.hpp
Go to the documentation of this file.
1#ifndef FSTREGRESSOR_H
2#define FSTREGRESSOR_H
3 /*
27=========================================================================
28Copyright and license:
29 * FST4 software (with the exception of any bundled or externally linked
30 third-party components) is Copyright (C) 2000-present Institute of
31 Information Theory and Automation of the Czech Academy of Sciences (UTIA).
32 * FST4 is free software: you can redistribute it and/or modify it under
33 the terms of the GNU Affero General Public License as published by the
34 Free Software Foundation, version 3. The full text of the license is in
35 the file LICENSE in the distribution root and at
36 https://www.gnu.org/licenses/agpl-3.0.html.
37 * FST4 is distributed in the hope that it will be useful, but WITHOUT ANY
38 WARRANTY; without even the implied warranty of MERCHANTABILITY or
39 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
40 License for more details.
41 * Closed-source use without the AGPL's copyleft obligations requires a
42 commercial license from UTIA; in case of interest write to
43 utia@utia.cas.cz. LICENSING.md in the distribution root explains both
44 options, the contributor license agreement that every contribution
45 requires, and the contacts (technical questions and pull requests:
46 somol@utia.cas.cz, with "FST" in the subject line).
47========================================================================== */
48
49#include <memory>
50#include "clonable.hpp"
51#include "wrapper_metrics.hpp"
52#include "error.hpp"
53#include "global.hpp"
54
55/*============== Template parameter type naming conventions ==============
56--------- Numeric types: -------------------------------------------------
57DATATYPE - data sample values - usually real numbers (but may be integers
58 in text processing etc.)
59REALTYPE - must be real numbers - for representing intermediate results of
60 calculations like mean, covariance etc.
61IDXTYPE - index values for enumeration of data samples - (nonnegative) integers,
62 extent depends on numbers of samples in data
63DIMTYPE - index values for enumeration of features (dimensions), or classes (not
64 class sizes) - (nonnegative) integers, usually lower extent than IDXTYPE,
65 but be aware of expressions like _classes*_features*_features !
66 in linearized representations of feature matrices for all classes
67BINTYPE - feature selection marker type - represents ca. <10 different feature
68 states (selected, deselected, sel./desel. temporarily 1st nested loop, 2nd...)
69RETURNTYPE - criterion value: real value, but may be extended in future to support
70 multiple values
71--------- Class types: ---------------------------------------------------
72SUBSET - class of class type Subset
73CLASSIFIER - class implementing interface defined in abstract class Classifier
74EVALUATOR - class implementing interface defined in abstract class Sequential_Step
75DISTANCE - class implementing interface defined in abstract class Distance
76DATAACCESSOR - class implementing interface defined in abstract class Data_Accessor
77INTERVALCONTAINER - class of class type Data_Intervaller
78CONTAINER - STL container of class type Data_Interval
79========================================================================== */
80
81namespace FST {
82
101template<class RETURNTYPE, typename DIMTYPE, class SUBSET, class DATAACCESSOR>
102class Regressor : public Clonable { // abstract class
103public:
104 typedef std::shared_ptr<DATAACCESSOR> PDataAccessor;
105 typedef std::shared_ptr<SUBSET> const PSubset;
106 typedef typename DATAACCESSOR::PPattern PPattern;
107 Regressor() {}
108 virtual ~Regressor() {}
109
114 virtual bool predict(RETURNTYPE &depvar, const PPattern &pattern) =0;
115 virtual bool train(const PDataAccessor da, const PSubset sub) =0;
119 virtual bool test(RETURNTYPE &result, const PDataAccessor da) =0;
120
125 virtual bool test_metric(RETURNTYPE &result, const PDataAccessor da, const Metric_Spec<RETURNTYPE> &spec)
126 {if(spec.is_default()) return test(result,da); (void)result; (void)da; return false;}
127
128 Regressor* clone() const override =0;
129 Regressor* sharing_clone() const override {throw fst_error("Regressor::sharing_clone() not supported, use Regressor::clone() instead.");}
130 Regressor* stateless_clone() const override {throw fst_error("Regressor::stateless_clone() not supported, use Regressor::clone() instead.");}
131};
132
133} // namespace
134#endif // FSTREGRESSOR_H ///:~
abstract class, defines interface for Regressor implementations (mainly to be used in wrappers)
Definition regressor.hpp:102
virtual bool train(const PDataAccessor da, const PSubset sub)=0
virtual bool test_metric(RETURNTYPE &result, const PDataAccessor da, const Metric_Spec< RETURNTYPE > &spec)
Definition regressor.hpp:125
virtual bool predict(RETURNTYPE &depvar, const PPattern &pattern)=0
Predicts the dependent variable of one pattern into depvar (see the dependent-variable convention in ...
DATAACCESSOR::PPattern PPattern
one data sample as exposed by DATAACCESSOR (a raw pointer to its feature vector)
Definition regressor.hpp:106
std::shared_ptr< SUBSET > const PSubset
shared pointer to the (fixed, non-reassignable) feature subset being evaluated
Definition regressor.hpp:105
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 (...
std::shared_ptr< DATAACCESSOR > PDataAccessor
shared pointer to the data accessor supplying train/test blocks
Definition regressor.hpp:104
Regressor * sharing_clone() const override
Definition regressor.hpp:129
Regressor * clone() const override=0
Regressor * stateless_clone() const override
Definition regressor.hpp:130
FST4 specific error passing class.
Definition error.hpp:61
Defines interface for classes that may need to get cloned.
FST4 specific error passing class.
Global definitions.
The Feature Selection Toolbox 4 library: every library component – data access, criteria and classifi...
Definition data_accessor.hpp:80
configuration of the wrapper metric; immutable during search, copied by criterion clones (thread-safe...
Definition wrapper_metrics.hpp:73
bool is_default() const
true iff this spec is the plain unweighted accuracy path (f1_positive is irrelevant unless metric==f1...
Definition wrapper_metrics.hpp:84
Wrapper criterion metrics beyond accuracy (balanced accuracy, F1, AUC, class weights,...
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.