Feature Selection Toolbox FST4
UTIA · Czech Academy of Sciences
Loading...
Searching...
No Matches
criterion.hpp
Go to the documentation of this file.
1#ifndef FSTCRITERION_H
2#define FSTCRITERION_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 "error.hpp"
51#include "global.hpp"
52#include "clonable.hpp"
53
54/*============== Template parameter type naming conventions ==============
55--------- Numeric types: -------------------------------------------------
56DATATYPE - data sample values - usually real numbers (but may be integers
57 in text processing etc.)
58REALTYPE - must be real numbers - for representing intermediate results of
59 calculations like mean, covariance etc.
60IDXTYPE - index values for enumeration of data samples - (nonnegative) integers,
61 extent depends on numbers of samples in data
62DIMTYPE - index values for enumeration of features (dimensions), or classes (not
63 class sizes) - (nonnegative) integers, usually lower extent than IDXTYPE,
64 but be aware of expressions like _classes*_features*_features !
65 in linearized representations of feature matrices for all classes
66BINTYPE - feature selection marker type - represents ca. <10 different feature
67 states (selected, deselected, sel./desel. temporarily 1st nested loop, 2nd...)
68RETURNTYPE - criterion value: real value, but may be extended in future to support
69 multiple values
70--------- Class types: ---------------------------------------------------
71SUBSET - class of class type Subset
72CLASSIFIER - class implementing interface defined in abstract class Classifier
73EVALUATOR - class implementing interface defined in abstract class Sequential_Step
74DISTANCE - class implementing interface defined in abstract class Distance
75DATAACCESSOR - class implementing interface defined in abstract class Data_Accessor
76INTERVALCONTAINER - class of class type Data_Intervaller
77CONTAINER - STL container of class type Data_Interval
78========================================================================== */
79
80namespace FST {
81
83template<class RETURNTYPE, class SUBSET>
84class Criterion : public Clonable { // abstract class
85public:
86 typedef std::shared_ptr<SUBSET> PSubset;
87 Criterion() {}
88 virtual ~Criterion() {}
89
100 virtual bool evaluate(RETURNTYPE &result, const PSubset sub) =0;
101
115 virtual bool is_monotonic() const {return false;}
116
117 Criterion* clone() const override =0;
118 Criterion* sharing_clone() const override {throw fst_error("Criterion::sharing_clone() not supported, use Criterion::clone() instead.");}
119 Criterion* stateless_clone() const override {throw fst_error("Criterion::stateless_clone() not supported, use Criterion::clone() instead.");}
120};
121
125template<class RETURNTYPE, class SUBSET>
126class Criterion_Filter : public Criterion<RETURNTYPE,SUBSET> { // abstract class
127public:
128 typedef std::shared_ptr<SUBSET> PSubset;
129 Criterion_Filter() {}
130 virtual ~Criterion_Filter() {}
131};
132
133
134} // namespace
135#endif // FSTCRITERION_H ///:~
Abstract class, defines interface for classes implementing "independent" feature selection criteria.
Definition criterion.hpp:126
std::shared_ptr< SUBSET > PSubset
shared pointer to the feature subset being evaluated
Definition criterion.hpp:128
Abstract class, defines interface for feature selection criterion classes.
Definition criterion.hpp:84
virtual bool evaluate(RETURNTYPE &result, const PSubset sub)=0
Scores the given feature subset; higher is better (FST4 searches maximize).
std::shared_ptr< SUBSET > PSubset
shared pointer to the feature subset being evaluated
Definition criterion.hpp:86
Criterion * stateless_clone() const override
Definition criterion.hpp:119
Criterion * sharing_clone() const override
Definition criterion.hpp:118
virtual bool is_monotonic() const
Definition criterion.hpp:115
Criterion * clone() const override=0
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
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.