forpy  2
forpy::ClassificationOpt Class Reference

Optimize split thresholds to optimize classification results. More...

#include <classification_opt.h>

Inheritance diagram for forpy::ClassificationOpt:
forpy::IThreshOpt forpy::FastClassOpt

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< IThreshOptcreate_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...
 
- Public Member Functions inherited from forpy::IThreshOpt
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< IEntropyFunctionentropy_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

- Protected Member Functions inherited from forpy::IThreshOpt
 IThreshOpt ()
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ ClassificationOpt()

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) 
)
Parameters
n_thresholdssize_t>=0 Number of randomly drawn threshold values that are assessed. If set to 0, the perfect split is determined. Default: 0.
gain_thresholdfloat >=0.f The minimum information gain a split has to achieve. Default: 1E-7f.
entropy_functionThe entropy function to use for gain calculation during the optimization.

Member Function Documentation

◆ check_annotations()

virtual void forpy::ClassificationOpt::check_annotations ( IDataProvider dprov)
virtual

Interface implementation.

Reimplemented from forpy::IThreshOpt.

◆ create_duplicate()

virtual std::shared_ptr<IThreshOpt> forpy::ClassificationOpt::create_duplicate ( const uint ) const
inlinevirtual

Interface implementation.

Reimplemented from forpy::IThreshOpt.

Reimplemented in forpy::FastClassOpt.

Definition at line 73 of file classification_opt.h.

◆ DISALLOW_COPY_AND_ASSIGN()

forpy::ClassificationOpt::DISALLOW_COPY_AND_ASSIGN ( ClassificationOpt  )
private

◆ full_entropy()

virtual void forpy::ClassificationOpt::full_entropy ( const IDataProvider dprov,
Desk  
) const
virtual

Interface implementation.

Reimplemented from forpy::IThreshOpt.

Reimplemented in forpy::FastClassOpt.

◆ get_class_translation()

std::shared_ptr<std::vector<uint> > forpy::ClassificationOpt::get_class_translation ( ) const
inline

Definition at line 98 of file classification_opt.h.

◆ get_gain_threshold_for()

float forpy::ClassificationOpt::get_gain_threshold_for ( const size_t &  )
inlinevirtual

Interface implementation.

Reimplemented from forpy::IThreshOpt.

Definition at line 90 of file classification_opt.h.

◆ get_n_classes()

size_t forpy::ClassificationOpt::get_n_classes ( ) const
inline

Get the determined number of classes.

Definition at line 96 of file classification_opt.h.

◆ get_true_max_class()

uint forpy::ClassificationOpt::get_true_max_class ( ) const
inline

Definition at line 102 of file classification_opt.h.

◆ operator==()

bool forpy::ClassificationOpt::operator== ( const IThreshOpt rhs) const
virtual

Reimplemented from forpy::IThreshOpt.

Reimplemented in forpy::FastClassOpt.

◆ optimize()

virtual void forpy::ClassificationOpt::optimize ( Desk ) const
virtual

Interface implementation.

Reimplemented from forpy::IThreshOpt.

Reimplemented in forpy::FastClassOpt.

◆ optimize__setup()

template<typename IT >
SplitOptRes<IT>& forpy::ClassificationOpt::optimize__setup ( DeciderDesk d) const
inlineprivate

◆ optimize__sort()

template<typename IT >
void forpy::ClassificationOpt::optimize__sort ( DeciderDesk d) const
inlineprivate

◆ optimize__thresholds()

template<typename IT >
std::unique_ptr<std::vector<IT> > forpy::ClassificationOpt::optimize__thresholds ( Desk d) const
inlineprivate

◆ serialize()

template<class Archive >
void forpy::ClassificationOpt::serialize ( Archive &  ar,
const uint  
)
inlineprivate

Definition at line 128 of file classification_opt.h.

◆ transfer_or_run_check()

void forpy::ClassificationOpt::transfer_or_run_check ( IThreshOpt other,
IDataProvider dprov 
)
inlinevirtual

Interface implementation.

Reimplemented from forpy::IThreshOpt.

Definition at line 79 of file classification_opt.h.

Friends And Related Function Documentation

◆ cereal::access

friend class cereal::access
friend

Definition at line 126 of file classification_opt.h.

◆ operator<<

std::ostream& operator<< ( std::ostream &  stream,
const ClassificationOpt  
)
friend

Definition at line 104 of file classification_opt.h.

Member Data Documentation

◆ class_transl_ptr

std::shared_ptr<std::vector<uint> > forpy::ClassificationOpt::class_transl_ptr
protected

Definition at line 116 of file classification_opt.h.

◆ entropy_func

std::shared_ptr<IEntropyFunction> forpy::ClassificationOpt::entropy_func
protected

Definition at line 115 of file classification_opt.h.

◆ gain_threshold

float forpy::ClassificationOpt::gain_threshold
protected

Definition at line 114 of file classification_opt.h.

◆ n_classes

size_t forpy::ClassificationOpt::n_classes
protected

Definition at line 113 of file classification_opt.h.

◆ n_thresholds

size_t forpy::ClassificationOpt::n_thresholds
protected

Definition at line 112 of file classification_opt.h.

◆ true_max

int forpy::ClassificationOpt::true_max
protected

Definition at line 117 of file classification_opt.h.


The documentation for this class was generated from the following file: