forpy
2
|
A classifier manager for weak classifiers with a filter function, a feature calculation function and a thresholding. More...
#include <fastdecider.h>
Public Member Functions | |
FastDecider (const std::shared_ptr< IThreshOpt > &threshold_optimizer=nullptr, const size_t &n_valid_features_to_use=0, const bool &autoscale_valid_features=false) | |
virtual std::shared_ptr< IDecider > | create_duplicate (const uint &random_seed) const |
bool | is_compatible_with (const IDataProvider &dprov) |
void | transfer_or_run_check (const std::shared_ptr< IDecider > &other, IDataProvider *dprov) |
void | set_data_dim (const size_t &val) |
void | ensure_capacity (const size_t &n_samples) |
void | finalize_capacity (const size_t &size) |
void | make_node (const TodoMark &todo_info, const uint &min_samples_at_leaf, const IDataProvider &data_provider, Desk *d) const |
Optimizes a classifier for the given data and stores the params. More... | |
bool | decide (const id_t &node_id, const Data< MatCRef > &data_v, const std::function< void(void *)> &decision_param_transf=nullptr) const |
Makes a decision for a node with already optimized parameters. More... | |
bool | supports_weights () const |
Whether this classifier manager supports sample weights during training. More... | |
size_t | get_data_dim () const |
std::shared_ptr< IThreshOpt > | get_threshopt () const |
bool | operator== (const IDecider &rhs) const |
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 |
![]() | |
virtual | ~IDecider () |
Private Member Functions | |
template<class Archive > | |
void | serialize (Archive &ar, const uint &) |
void | _make_node__checks (const TodoMark &todo_info, const IDataProvider &data_provider, const uint &min_samples_at_leaf, Desk *d) const |
void | _make_node__opt (const IDataProvider &dprov, Desk *d) const |
void | _make_node__postprocess (const IDataProvider &dprov, Desk *d) const |
Private Attributes | |
std::shared_ptr< IThreshOpt > | threshold_optimizer |
size_t | n_valids_to_use |
bool | autoscale_valid_features |
std::vector< size_t > | node_to_featsel |
mu::variant< std::vector< float >, std::vector< double >, std::vector< uint32_t >, std::vector< uint8_t > > | node_to_thresh_v |
size_t | data_dim |
Friends | |
class | cereal::access |
std::ostream & | operator<< (std::ostream &stream, const FastDecider &self) |
Additional Inherited Members | |
![]() | |
IDecider () | |
Empty constructor to allow inheritance though DISALLOW_COPY_AND_ASSIGN is applied. More... | |
A classifier manager for weak classifiers with a filter function, a feature calculation function and a thresholding.
The classifier design is heavily inspired by "Decision Forests for Classification, Regression, Density Estimation, Manifold Learning and Semi-Supervised Learning" (Criminisi, Shotton and Konukoglu, 2011). With their definition, node classifier parameters \(\theta\) can be split into three parts:
With this model, a decision can be made at each node based on whether the calculated scalar lies withing the thresholding bounds.
Definition at line 45 of file fastdecider.h.
forpy::FastDecider::FastDecider | ( | const std::shared_ptr< IThreshOpt > & | threshold_optimizer = nullptr , |
const size_t & | n_valid_features_to_use = 0 , |
||
const bool & | autoscale_valid_features = false |
||
) |
threshold_optimizer | shared(IThreshOpt) Optimizes \(\tau\). |
n_valid_features_to_use | size_t The threshold optimizer may hint that a selected feature may be completely inappropriate for the currently searched split. If the feature selection provider does provide sufficiently many features, the classifier may use the next one and "not count" the inappropriate one. This is the maximum number of "valid" features that are used per split. If 0, ignore the flag returned by the optimizer and always use all suggested feature combinations provided by the feature selection provider. Default: 0. |
autoscale_valid_features | bool If set to true, automatically scale to sqrt(number of features) of the input data. |
|
private |
|
private |
|
private |
|
inlinevirtual |
Create an equivalent, but empty, duplicate.
Reimplemented from forpy::IDecider.
Definition at line 68 of file fastdecider.h.
|
virtual |
Makes a decision for a node with already optimized parameters.
The classifier parameters must have been optimized for the node_id before this method is called.
node_id | The node id of the node for which the decision should be made. |
data | The input data. |
dptf | Feature transformation function; currently unused. |
Reimplemented from forpy::IDecider.
|
inlinevirtual |
Reimplemented from forpy::IDecider.
Definition at line 113 of file fastdecider.h.
|
inlinevirtual |
Reimplemented from forpy::IDecider.
Definition at line 118 of file fastdecider.h.
|
virtual |
Gets the input dimension of the feature selection provider.
Reimplemented from forpy::IDecider.
|
virtual |
Implements forpy::IDecider.
|
virtual |
Reimplemented from forpy::IDecider.
|
inlinevirtual |
Reimplemented from forpy::IDecider.
Definition at line 78 of file fastdecider.h.
|
virtual |
Optimizes a classifier for the given data and stores the params.
This method must either set make_to_leaf to true or assure that at least the minimum amount of samples per leaf is contained in each of element_list_left and element_list_right. In the case that make_leaf is true, the list pointers may even be returned uninitialized.
If it is necessary to enforce additional growing constraints for the tree, this is the right place (e.g. have a minimum number of samples per node). The classifier manager can take these constraints into account and may return make_to_leaf accordingly.
Reimplemented from forpy::IDecider.
|
virtual |
Reimplemented from forpy::IDecider.
|
inlineprivate |
Definition at line 149 of file fastdecider.h.
|
inlinevirtual |
Reimplemented from forpy::IDecider.
Definition at line 111 of file fastdecider.h.
|
virtual |
Whether this classifier manager supports sample weights during training.
Reimplemented from forpy::IDecider.
|
inlinevirtual |
Reimplemented from forpy::IDecider.
Definition at line 99 of file fastdecider.h.
|
friend |
Definition at line 147 of file fastdecider.h.
|
friend |
Definition at line 135 of file fastdecider.h.
|
private |
Definition at line 168 of file fastdecider.h.
|
private |
Definition at line 173 of file fastdecider.h.
|
private |
Definition at line 167 of file fastdecider.h.
|
private |
Definition at line 169 of file fastdecider.h.
|
private |
Definition at line 172 of file fastdecider.h.
|
private |
Definition at line 166 of file fastdecider.h.