forpy  2
forpy::FastClassOpt Class Reference

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

#include <fastclassopt.h>

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

Public Member Functions

 FastClassOpt (const size_t &n_thresholds=0, const float &gain_threshold=1E-7f)
 
bool operator== (const IThreshOpt &rhs) const
 
virtual std::shared_ptr< IThreshOptcreate_duplicate (const uint &) const
 Interface implementation. More...
 
void full_entropy (const IDataProvider &dprov, Desk *) const
 Interface implementation. More...
 
void optimize (Desk *) const
 Interface implementation. More...
 
- Public Member Functions inherited from 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))
 
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
 
virtual void check_annotations (IDataProvider *dprov)
 Interface implementation. More...
 
void transfer_or_run_check (IThreshOpt *other, IDataProvider *dprov)
 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...
 

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 (FastClassOpt)
 

Private Attributes

std::shared_ptr< std::vector< uint > > class_transl_ptr
 
float gain_threshold
 
size_t n_classes
 
size_t n_thresholds
 
int true_max
 

Friends

class cereal::access
 
std::ostream & operator<< (std::ostream &stream, const FastClassOpt &)
 

Additional Inherited Members

- Protected Member Functions inherited from forpy::IThreshOpt
 IThreshOpt ()
 
- Protected Attributes inherited from forpy::ClassificationOpt
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
 

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 40 of file fastclassopt.h.

Constructor & Destructor Documentation

◆ FastClassOpt()

forpy::FastClassOpt::FastClassOpt ( const size_t &  n_thresholds = 0,
const float &  gain_threshold = 1E-7f 
)
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.

Member Function Documentation

◆ create_duplicate()

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

Interface implementation.

Reimplemented from forpy::ClassificationOpt.

Definition at line 54 of file fastclassopt.h.

◆ DISALLOW_COPY_AND_ASSIGN()

forpy::FastClassOpt::DISALLOW_COPY_AND_ASSIGN ( FastClassOpt  )
private

◆ full_entropy()

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

Interface implementation.

Reimplemented from forpy::ClassificationOpt.

◆ operator==()

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

Reimplemented from forpy::ClassificationOpt.

◆ optimize()

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

Interface implementation.

Reimplemented from forpy::ClassificationOpt.

◆ optimize__setup()

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

◆ optimize__sort()

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

◆ optimize__thresholds()

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

◆ serialize()

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

Definition at line 78 of file fastclassopt.h.

Friends And Related Function Documentation

◆ cereal::access

friend class cereal::access
friend

Definition at line 76 of file fastclassopt.h.

◆ operator<<

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

Definition at line 62 of file fastclassopt.h.

Member Data Documentation

◆ class_transl_ptr

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

Definition at line 116 of file classification_opt.h.

◆ gain_threshold

float forpy::ClassificationOpt::gain_threshold
private

Definition at line 114 of file classification_opt.h.

◆ n_classes

size_t forpy::ClassificationOpt::n_classes
private

Definition at line 113 of file classification_opt.h.

◆ n_thresholds

size_t forpy::ClassificationOpt::n_thresholds
private

Definition at line 112 of file classification_opt.h.

◆ true_max

int forpy::ClassificationOpt::true_max
private

Definition at line 117 of file classification_opt.h.


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