1#ifndef FSTCRITERIONWRAPPER_H
2#define FSTCRITERIONWRAPPER_H
94template<
class RETURNTYPE,
class SUBSET,
class CLASSIFIER,
class DATAACCESSOR>
95class Criterion_Wrapper :
public Clonable_Impl<Criterion_Wrapper<RETURNTYPE,SUBSET,CLASSIFIER,DATAACCESSOR>,Criterion<RETURNTYPE,SUBSET> > {
101 Criterion_Wrapper() {
notify(
"Criterion_Wrapper constructor.");}
122 virtual std::ostream&
print(std::ostream& os)
const override {os <<
"Criterion_Wrapper()";
if(
_classifier) os <<
" with " << *
_classifier;
return os;}
129 std::shared_ptr<DATAACCESSOR>
_da;
133template<
class RETURNTYPE,
class SUBSET,
class CLASSIFIER,
class DATAACCESSOR>
134Criterion_Wrapper<RETURNTYPE,SUBSET,CLASSIFIER,DATAACCESSOR>::Criterion_Wrapper(
const Criterion_Wrapper& cw)
136 notify(
"Criterion_Wrapper copy-constructor.");
144template<
class RETURNTYPE,
class SUBSET,
class CLASSIFIER,
class DATAACCESSOR>
153template<
class RETURNTYPE,
class SUBSET,
class CLASSIFIER,
class DATAACCESSOR>
165 for(
bool b=
_da->getFirstSplit();b==
true;b=
_da->getNextSplit()) {
172 if(cnt==0.0)
return false;
173 result/=(RETURNTYPE)cnt;
176 for(
bool b=
_da->getFirstSplit();b==
true;b=
_da->getNextSplit()) {
182 if(cnt==0.0)
return false;
183 result/=(RETURNTYPE)cnt;
CRTP mixin implementing the Clonable protocol for a concrete class.
Definition clonable.hpp:184
Wraps Classifier objects to serve as feature selection criterion.
Definition criterion_wrapper.hpp:95
Metric_Spec< RETURNTYPE > _metric_spec
Definition criterion_wrapper.hpp:130
virtual void initialize(const PClassifier classifier, const PDataAccessor da)
Stores the classifier and the data accessor to be used by every later evaluate(). Must be called befo...
Definition criterion_wrapper.hpp:145
const Metric_Spec< RETURNTYPE > & get_metric() const
returns the currently configured wrapper metric (see set_metric())
Definition criterion_wrapper.hpp:119
std::shared_ptr< SUBSET > PSubset
Definition criterion_wrapper.hpp:100
void set_metric(const Metric_Spec< RETURNTYPE > &spec)
Definition criterion_wrapper.hpp:118
Clonable_Impl< Criterion_Wrapper, Criterion< RETURNTYPE, SUBSET > > parent_impl
Definition criterion_wrapper.hpp:97
std::shared_ptr< REGRESSOR > _classifier
Definition criterion_wrapper.hpp:128
virtual bool evaluate(RETURNTYPE &result, const PSubset sub) override
Trains and tests the wrapped classifier on every split, returning the mean of the per-split values of...
Definition criterion_wrapper.hpp:154
virtual std::ostream & print(std::ostream &os) const override
writes a human-readable identification of the object; base default writes nothing
Definition criterion_wrapper.hpp:122
std::shared_ptr< REGRESSOR > PClassifier
Definition criterion_wrapper.hpp:98
std::shared_ptr< DATAACCESSOR > _da
Definition criterion_wrapper.hpp:129
Criterion_Wrapper(const Criterion_Wrapper &cw)
Copy-constructor; clones _classifier and sharing-clones _da, copies _metric_spec.
Definition criterion_wrapper.hpp:134
std::shared_ptr< DATAACCESSOR > PDataAccessor
Definition criterion_wrapper.hpp:99
Defines interface for feature selection criterion classes.
FST4 specific error passing class.
The Feature Selection Toolbox 4 library: every library component – data access, criteria and classifi...
Definition data_accessor.hpp:80
void notify(const std::string msg)
Prints msg followed by a newline via syncout::print(); a no-op unless the preprocessor macro DEBUG is...
Definition global.hpp:112
std::unique_ptr< T > clone_unique(const T &src)
Definition clonable.hpp:234
std::unique_ptr< T > sharing_clone_unique(const T &src)
sharing_clone() counterpart of clone_unique() – see its comment above.
Definition clonable.hpp:239
configuration of the wrapper metric; immutable during search, copied by criterion clones (thread-safe...
Definition wrapper_metrics.hpp:73
Wrapper criterion metrics beyond accuracy (balanced accuracy, F1, AUC, class weights,...