forpy  2
idecider.h
Go to the documentation of this file.
1 /* Author: Christoph Lassner. */
2 #pragma once
3 #ifndef FORPY_DECIDERS_IDECIDER_H_
4 #define FORPY_DECIDERS_IDECIDER_H_
5 
6 #include "../global.h"
7 
8 #include "../util/serialization/basics.h"
9 
10 #include <limits>
11 #include <utility>
12 #include <vector>
13 
14 #include "../data_providers/idataprovider.h"
15 #include "../threshold_optimizers/ithreshopt.h"
16 #include "../types.h"
17 #include "../util/desk.h"
18 
19 namespace forpy {
31 class IDecider {
32  public:
33  virtual ~IDecider();
34 
36  virtual std::shared_ptr<IDecider> create_duplicate(
37  const uint &random_seed) const VIRTUAL_PTR;
38 
52  virtual void make_node(const TodoMark &todo_info,
53  const uint &min_samples_at_leaf,
54  const IDataProvider &data_provider,
55  Desk *d) const VIRTUAL_VOID;
56 
57  virtual bool is_compatible_with(const IDataProvider &dprov) VIRTUAL(bool);
58 
59  virtual void transfer_or_run_check(const std::shared_ptr<IDecider> &other,
61 
62  virtual void ensure_capacity(const size_t &n_samples) VIRTUAL_VOID;
63 
64  virtual void finalize_capacity(const size_t &size) VIRTUAL_VOID;
65 
78  virtual bool decide(const id_t &node_id, const Data<MatCRef> &data,
79  const std::function<void(void *)> &dptf = nullptr) const
80  VIRTUAL(bool);
81 
86  virtual bool supports_weights() const VIRTUAL(bool);
87 
89  virtual size_t get_data_dim() const VIRTUAL(size_t);
90 
91  virtual void set_data_dim(const size_t &val) VIRTUAL_VOID;
92 
93  virtual std::shared_ptr<IThreshOpt> get_threshopt() const VIRTUAL_PTR;
94 
95  virtual bool operator==(const IDecider &rhs) const VIRTUAL(bool);
96 
97  std::pair<const std::vector<size_t> *,
98  const mu::variant<std::vector<float>, std::vector<double>,
99  std::vector<uint32_t>, std::vector<uint8_t>>
100  *> virtual get_maps() const = 0;
101 
102  protected:
107  IDecider();
108 
109  private:
110  friend class cereal::access;
111  template <class Archive>
112  void serialize(Archive &, const uint &){};
113 
115 };
116 
117 } // namespace forpy
118 #endif // FORPY_DECIDERS_IDECIDER_H_
IDecider()
Empty constructor to allow inheritance though DISALLOW_COPY_AND_ASSIGN is applied.
virtual std::shared_ptr< IThreshOpt > get_threshopt() const VIRTUAL_PTR
#define VIRTUAL_VOID
Definition: global.h:32
virtual ~IDecider()
virtual void make_node(const TodoMark &todo_info, const uint &min_samples_at_leaf, const IDataProvider &data_provider, Desk *d) const VIRTUAL_VOID
Optimizes a classifier for the given data and stores the params.
A data provider for the training of one tree.
Definition: idataprovider.h:22
size_t id_t
Element id type.
Definition: types.h:106
typename mu::variant< Empty, STOT< float >, STOT< double >, STOT< uint >, STOT< uint8_t > > Data
Storing a variant of the provided data container type.
Definition: storage.h:126
#define VIRTUAL_PTR
Definition: global.h:33
#define VIRTUAL(type)
Definition: global.h:31
virtual void ensure_capacity(const size_t &n_samples) VIRTUAL_VOID
Stores the parameters for one marked tree node.
Definition: types.h:152
void serialize(Archive &, const uint &)
Definition: idecider.h:112
friend class cereal::access
Definition: idecider.h:110
virtual bool decide(const id_t &node_id, const Data< MatCRef > &data, const std::function< void(void *)> &dptf=nullptr) const VIRTUAL(bool)
Makes a decision for a node with already optimized parameters.
DISALLOW_COPY_AND_ASSIGN(IDecider)
virtual bool operator==(const IDecider &rhs) const VIRTUAL(bool)
virtual size_t get_data_dim() const VIRTUAL(size_t)
virtual std::pair< const std::vector< size_t > *, const mu::variant< std::vector< float >, std::vector< double >, std::vector< uint32_t >, std::vector< uint8_t > > * > get_maps() const =0
virtual bool supports_weights() const VIRTUAL(bool)
Whether this classifier manager supports sample weights during training.
Main thread desk object.
Definition: desk.h:201
virtual std::shared_ptr< IDecider > create_duplicate(const uint &random_seed) const VIRTUAL_PTR
virtual void finalize_capacity(const size_t &size) VIRTUAL_VOID
Interface for the decider. It does the optimization of the deciding classifier for each node and stor...
Definition: idecider.h:31
unsigned int uint
Convenience typedef for unsigned int.
Definition: types.h:113
virtual bool is_compatible_with(const IDataProvider &dprov) VIRTUAL(bool)
virtual void transfer_or_run_check(const std::shared_ptr< IDecider > &other, IDataProvider *dprov) VIRTUAL_VOID
virtual void set_data_dim(const size_t &val) VIRTUAL_VOID