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,
60 IDataProvider *dprov) VIRTUAL_VOID;
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
114 DISALLOW_COPY_AND_ASSIGN(IDecider);
115 };
116
117 } // namespace forpy
118 #endif // FORPY_DECIDERS_IDECIDER_H_
forpy::IDecider::IDecider
IDecider()
Empty constructor to allow inheritance though DISALLOW_COPY_AND_ASSIGN is applied.
forpy::IDecider::get_threshopt
virtual std::shared_ptr< IThreshOpt > get_threshopt() const VIRTUAL_PTR
VIRTUAL_VOID
#define VIRTUAL_VOID
Definition: global.h:32
forpy::IDecider::~IDecider
virtual ~IDecider()
forpy::IDecider::make_node
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.
forpy::IDataProvider
A data provider for the training of one tree.
Definition: idataprovider.h:22
forpy::id_t
size_t id_t
Element id type.
Definition: types.h:106
forpy::Data
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
VIRTUAL_PTR
#define VIRTUAL_PTR
Definition: global.h:33
VIRTUAL
#define VIRTUAL(type)
Definition: global.h:31
forpy::IDecider::ensure_capacity
virtual void ensure_capacity(const size_t &n_samples) VIRTUAL_VOID
forpy::TodoMark
Stores the parameters for one marked tree node.
Definition: types.h:152
forpy::IDecider::serialize
void serialize(Archive &, const uint &)
Definition: idecider.h:112
forpy::IDecider::access
friend class cereal::access
Definition: idecider.h:110
forpy::IDecider::decide
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.
forpy::IDecider::DISALLOW_COPY_AND_ASSIGN
DISALLOW_COPY_AND_ASSIGN(IDecider)
forpy::IDecider::operator==
virtual bool operator==(const IDecider &rhs) const VIRTUAL(bool)
forpy::IDecider::get_data_dim
virtual size_t get_data_dim() const VIRTUAL(size_t)
forpy::IDecider::get_maps
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
forpy
Definition: fastdprov.h:13
forpy::IDecider::supports_weights
virtual bool supports_weights() const VIRTUAL(bool)
Whether this classifier manager supports sample weights during training.
forpy::Desk
Main thread desk object.
Definition: desk.h:201
forpy::IDecider::create_duplicate
virtual std::shared_ptr< IDecider > create_duplicate(const uint &random_seed) const VIRTUAL_PTR
forpy::IDecider::finalize_capacity
virtual void finalize_capacity(const size_t &size) VIRTUAL_VOID
forpy::IDecider
Interface for the decider. It does the optimization of the deciding classifier for each node and stor...
Definition: idecider.h:31
forpy::uint
unsigned int uint
Convenience typedef for unsigned int.
Definition: types.h:113
forpy::IDecider::is_compatible_with
virtual bool is_compatible_with(const IDataProvider &dprov) VIRTUAL(bool)
forpy::IDecider::transfer_or_run_check
virtual void transfer_or_run_check(const std::shared_ptr< IDecider > &other, IDataProvider *dprov) VIRTUAL_VOID
forpy::IDecider::set_data_dim
virtual void set_data_dim(const size_t &val) VIRTUAL_VOID