forpy
2
|
Optimize split thresholds to optimize classification results. More...
#include <classification_opt.h>
Public Member Functions | |
ClassificationOpt (const size_t &n_thresholds=0, const float &gain_threshold=1E-7f, const std::shared_ptr< IEntropyFunction > &entropy_function=std::make_shared< InducedEntropy >(2)) | |
size_t | get_n_classes () const |
Get the determined number of classes. More... | |
std::shared_ptr< std::vector< uint > > | get_class_translation () const |
uint | get_true_max_class () const |
bool | operator== (const IThreshOpt &rhs) const |
virtual std::shared_ptr< IThreshOpt > | create_duplicate (const uint &) const |
Interface implementation. More... | |
virtual void | check_annotations (IDataProvider *dprov) |
Interface implementation. More... | |
void | transfer_or_run_check (IThreshOpt *other, IDataProvider *dprov) |
Interface implementation. More... | |
virtual void | full_entropy (const IDataProvider &dprov, Desk *) const |
Interface implementation. More... | |
virtual void | optimize (Desk *) const |
Interface implementation. More... | |
float | get_gain_threshold_for (const size_t &) |
Interface implementation. More... | |
![]() | |
virtual | ~IThreshOpt () |
virtual bool | supports_weights () const |
Whether this threshold optimizer can take into account weights during the optimization. More... | |
Protected Attributes | |
size_t | n_thresholds |
size_t | n_classes |
float | gain_threshold |
std::shared_ptr< IEntropyFunction > | entropy_func |
std::shared_ptr< std::vector< uint > > | class_transl_ptr |
int | true_max |
Private Member Functions | |
template<typename IT > | |
SplitOptRes< IT > & | optimize__setup (DeciderDesk &d) const |
template<typename IT > | |
void | optimize__sort (DeciderDesk &d) const |
template<typename IT > | |
std::unique_ptr< std::vector< IT > > | optimize__thresholds (Desk *d) const |
template<class Archive > | |
void | serialize (Archive &ar, const uint &) |
DISALLOW_COPY_AND_ASSIGN (ClassificationOpt) | |
Friends | |
class | cereal::access |
std::ostream & | operator<< (std::ostream &stream, const ClassificationOpt &) |
Additional Inherited Members | |
![]() | |
IThreshOpt () | |
Optimize split thresholds to optimize classification results.
This threshold optimizer draws n_thresholds
random values between the minimum and maximum observed feature value and returns the best one, or finds the perfect split if n_thresholds == 0
.
The optimizer is robust w.r.t. scaling of the features up to a certain extent. It is important that the least noticable difference is larger than 1E-7 (forpy::CLASSOPT_EPS).
Definition at line 55 of file classification_opt.h.
forpy::ClassificationOpt::ClassificationOpt | ( | const size_t & | n_thresholds = 0 , |
const float & | gain_threshold = 1E-7f , |
||
const std::shared_ptr< IEntropyFunction > & | entropy_function = std::make_shared< InducedEntropy >(2) |
||
) |
n_thresholds | size_t>=0 Number of randomly drawn threshold values that are assessed. If set to 0, the perfect split is determined. Default: 0. |
gain_threshold | float >=0.f The minimum information gain a split has to achieve. Default: 1E-7f. |
entropy_function | The entropy function to use for gain calculation during the optimization. |
|
virtual |
Interface implementation.
Reimplemented from forpy::IThreshOpt.
|
inlinevirtual |
Interface implementation.
Reimplemented from forpy::IThreshOpt.
Reimplemented in forpy::FastClassOpt.
Definition at line 73 of file classification_opt.h.
|
private |
|
virtual |
Interface implementation.
Reimplemented from forpy::IThreshOpt.
Reimplemented in forpy::FastClassOpt.
|
inline |
Definition at line 98 of file classification_opt.h.
|
inlinevirtual |
Interface implementation.
Reimplemented from forpy::IThreshOpt.
Definition at line 90 of file classification_opt.h.
|
inline |
Get the determined number of classes.
Definition at line 96 of file classification_opt.h.
|
inline |
Definition at line 102 of file classification_opt.h.
|
virtual |
Reimplemented from forpy::IThreshOpt.
Reimplemented in forpy::FastClassOpt.
|
virtual |
Interface implementation.
Reimplemented from forpy::IThreshOpt.
Reimplemented in forpy::FastClassOpt.
|
inlineprivate |
|
inlineprivate |
|
inlineprivate |
|
inlineprivate |
Definition at line 128 of file classification_opt.h.
|
inlinevirtual |
Interface implementation.
Reimplemented from forpy::IThreshOpt.
Definition at line 79 of file classification_opt.h.
|
friend |
Definition at line 126 of file classification_opt.h.
|
friend |
Definition at line 104 of file classification_opt.h.
|
protected |
Definition at line 116 of file classification_opt.h.
|
protected |
Definition at line 115 of file classification_opt.h.
|
protected |
Definition at line 114 of file classification_opt.h.
|
protected |
Definition at line 113 of file classification_opt.h.
|
protected |
Definition at line 112 of file classification_opt.h.
|
protected |
Definition at line 117 of file classification_opt.h.