forpy  2
fastclassopt.h
Go to the documentation of this file.
1 /* Author: Christoph Lassner. */
2 #pragma once
3 #ifndef FORPY_THRESHOLD_OPTIMIZERS_FASTCLASSOPT_H_
4 #define FORPY_THRESHOLD_OPTIMIZERS_FASTCLASSOPT_H_
5 
6 #include "../global.h"
7 #include "../util/serialization/basics.h"
8 
9 #include "../impurities/ientropyfunction.h"
10 #include "../impurities/shannonentropy.h"
11 #include "../types.h"
12 #include "../util/desk.h"
13 #include "./classification_opt.h"
14 #include "./ithreshopt.h"
15 
16 namespace forpy {
17 
18 #pragma clang diagnostic push
19 #pragma clang diagnostic ignored "-Wunused-variable"
20 
21 const int DLOG_FCOPT_V = 100;
23 const size_t LOG_FCOPT_NID = 3;
24 const bool LOG_FCOPT_ALLN = true;
26 
41  public:
49  FastClassOpt(const size_t &n_thresholds = 0,
50  const float &gain_threshold = 1E-7f);
51 
53  virtual std::shared_ptr<IThreshOpt> create_duplicate(
55  const uint & /*random_seed*/) const {
56  return std::make_shared<FastClassOpt>(n_thresholds, gain_threshold);
57  }
58  void full_entropy(const IDataProvider &dprov, Desk *) const;
59  void optimize(Desk *) const;
61 
62  inline friend std::ostream &operator<<(std::ostream &stream,
63  const FastClassOpt & /*self*/) {
64  stream << "forpy::FastClassOpt";
65  return stream;
66  };
67  bool operator==(const IThreshOpt &rhs) const;
68 
69  private:
70  template <typename IT>
72  template <typename IT>
73  inline void optimize__sort(DeciderDesk &d) const;
74  template <typename IT>
75  inline std::unique_ptr<std::vector<IT>> optimize__thresholds(Desk *d) const;
76  friend class cereal::access;
77  template <class Archive>
78  void serialize(Archive &ar, const uint &) {
79  ar(cereal::make_nvp("base", cereal::base_class<ClassificationOpt>(this)));
80  }
81 
88 };
89 } // namespace forpy
90 
92 #endif // FORPY_THRESHOLD_OPTIMIZERS_FASTCLASSOPT_H_
friend std::ostream & operator<<(std::ostream &stream, const FastClassOpt &)
Definition: fastclassopt.h:62
Find an optimal threshold.
Definition: ithreshopt.h:23
Desk for decider training.
Definition: desk.h:61
void serialize(Archive &ar, const uint &)
Definition: fastclassopt.h:78
A data provider for the training of one tree.
Definition: idataprovider.h:22
friend class cereal::access
Definition: fastclassopt.h:76
DISALLOW_COPY_AND_ASSIGN(FastClassOpt)
const bool LOG_FCOPT_ALLN
Variables to control debugging and log output for the forpy::RegressionOpt.
Definition: fastclassopt.h:24
void optimize(Desk *) const
Interface implementation.
const size_t LOG_FCOPT_NID
Variables to control debugging and log output for the forpy::RegressionOpt.
Definition: fastclassopt.h:23
std::shared_ptr< std::vector< uint > > class_transl_ptr
Optimize split thresholds to optimize classification results.
const int DLOG_FCOPT_V
Variables to control debugging and log output for the forpy::RegressionOpt.
Definition: fastclassopt.h:22
void optimize__sort(DeciderDesk &d) const
SplitOptRes< IT > & optimize__setup(DeciderDesk &d) const
std::unique_ptr< std::vector< IT > > optimize__thresholds(Desk *d) const
Main thread desk object.
Definition: desk.h:201
Optimize split thresholds to optimize classification results.
Definition: fastclassopt.h:40
bool operator==(const IThreshOpt &rhs) const
void full_entropy(const IDataProvider &dprov, Desk *) const
Interface implementation.
virtual std::shared_ptr< IThreshOpt > create_duplicate(const uint &) const
Interface implementation.
Definition: fastclassopt.h:54
unsigned int uint
Convenience typedef for unsigned int.
Definition: types.h:113
CEREAL_REGISTER_TYPE(forpy::FastClassOpt)
FastClassOpt(const size_t &n_thresholds=0, const float &gain_threshold=1E-7f)