forpy 2

Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
forpy::FastDecider Class Reference
Deciders

A classifier manager for weak classifiers with a filter function, a feature calculation function and a thresholding. More...

`#include <fastdecider.h>`

Inheritance diagram for forpy::FastDecider:

## 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
Public Member Functions inherited from forpy::IDecider
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
Protected Member Functions inherited from forpy::IDecider
| IDecider ()
| Empty constructor to allow inheritance though DISALLOW_COPY_AND_ASSIGN is applied. More...

## Detailed Description

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:

- \(\tau\): thresholding parameters for the calculated scalar.

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.

## Constructor & Destructor Documentation

## ◆ FastDecider()

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`
| ) |  |

Parameters

  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.

## Member Function Documentation

## ◆ _make_node__checks()

void forpy::FastDecider::_make_node__checks | ( | const TodoMark & | todo_info,
|  | const IDataProvider & | data_provider,
|  | const uint & | min_samples_at_leaf,
|  | Desk * | d
| ) |  | const
| private

## ◆ _make_node__opt()

void forpy::FastDecider::_make_node__opt | ( | const IDataProvider & | dprov,
|  | Desk * | d
| ) |  | const
| private

## ◆ _make_node__postprocess()

void forpy::FastDecider::_make_node__postprocess | ( | const IDataProvider & | dprov,
|  | Desk * | d
| ) |  | const
| private

## ◆ create_duplicate()

virtual std::shared_ptr<IDecider> forpy::FastDecider::create_duplicate | ( | const uint & | random_seed | ) | const
| inline virtual

Create an equivalent, but empty, duplicate.

Reimplemented from forpy::IDecider.

Definition at line 68 of file fastdecider.h.

## ◆ decide()

bool forpy::FastDecider::decide | ( | const id_t & | node_id,
|  | const Data< MatCRef > & | data,
|  | const std::function< void(void *)> & | dptf = `nullptr`
| ) |  | const
| 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.

Parameters

  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.

Returns
  true, if the decision goes to left, false otherwise.

Reimplemented from forpy::IDecider.

## ◆ ensure_capacity()

void forpy::FastDecider::ensure_capacity | ( | const size_t & | n_samples | ) |
| inline virtual

Reimplemented from forpy::IDecider.

Definition at line 113 of file fastdecider.h.

## ◆ finalize_capacity()

void forpy::FastDecider::finalize_capacity | ( | const size_t & | size | ) |
| inline virtual

Reimplemented from forpy::IDecider.

Definition at line 118 of file fastdecider.h.

## ◆ get_data_dim()

size_t forpy::FastDecider::get_data_dim | ( |  | ) | const
| virtual

Gets the input dimension of the feature selection provider.

Reimplemented from forpy::IDecider.

## ◆ get_maps()

std::pair<const std::vector<size_t> *, const mu::variant<std::vector<float>, std::vector<double>, std::vector<uint32_t>, std::vector<uint8_t> > *> forpy::FastDecider::get_maps | ( |  | ) | const
| virtual

Implements forpy::IDecider.

## ◆ get_threshopt()

std::shared_ptr<IThreshOpt> forpy::FastDecider::get_threshopt | ( |  | ) | const
| virtual

Reimplemented from forpy::IDecider.

## ◆ is_compatible_with()

bool forpy::FastDecider::is_compatible_with | ( | const IDataProvider & | dprov | ) |
| inline virtual

Reimplemented from forpy::IDecider.

Definition at line 78 of file fastdecider.h.

## ◆ make_node()

void forpy::FastDecider::make_node | ( | const TodoMark & | todo_info,
|  | const uint & | min_samples_at_leaf,
|  | const IDataProvider & | data_provider,
|  | Desk * | d
| ) |  | const
| 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.

## ◆ operator==()

bool forpy::FastDecider::operator== | ( | const IDecider & | rhs | ) | const
| virtual

Reimplemented from forpy::IDecider.

## ◆ serialize()

template<class Archive >

void forpy::FastDecider::serialize | ( | Archive & | ar,
|  | const uint & |
| ) |  |
| inline private

Definition at line 149 of file fastdecider.h.

## ◆ set_data_dim()

void forpy::FastDecider::set_data_dim | ( | const size_t & | val | ) |
| inline virtual

Reimplemented from forpy::IDecider.

Definition at line 111 of file fastdecider.h.

## ◆ supports_weights()

bool forpy::FastDecider::supports_weights | ( |  | ) | const
| virtual

Whether this classifier manager supports sample weights during training.

Reimplemented from forpy::IDecider.

## ◆ transfer_or_run_check()

void forpy::FastDecider::transfer_or_run_check | ( | const std::shared_ptr< IDecider > & | other,
|  | IDataProvider * | dprov
| ) |  |
| inline virtual

Reimplemented from forpy::IDecider.

Definition at line 99 of file fastdecider.h.

## Friends And Related Function Documentation

## ◆ cereal::access

friend class cereal::access
| friend

Definition at line 147 of file fastdecider.h.

## ◆ operator<<

std::ostream& operator<< | ( | std::ostream & | stream,
|  | const FastDecider & | self
| ) |  |
| friend

Definition at line 135 of file fastdecider.h.

## Member Data Documentation

## ◆ autoscale_valid_features

bool forpy::FastDecider::autoscale_valid_features
| private

Definition at line 168 of file fastdecider.h.

## ◆ data_dim

size_t forpy::FastDecider::data_dim
| private

Definition at line 173 of file fastdecider.h.

## ◆ n_valids_to_use

size_t forpy::FastDecider::n_valids_to_use
| private

Definition at line 167 of file fastdecider.h.

## ◆ node_to_featsel

std::vector<size_t> forpy::FastDecider::node_to_featsel
| private

Definition at line 169 of file fastdecider.h.

## ◆ node_to_thresh_v

mu::variant<std::vector<float>, std::vector<double>, std::vector<uint32_t>, std::vector<uint8_t> > forpy::FastDecider::node_to_thresh_v
| private

Definition at line 172 of file fastdecider.h.

## ◆ threshold_optimizer

std::shared_ptr<IThreshOpt> forpy::FastDecider::threshold_optimizer
| private

Definition at line 166 of file fastdecider.h.

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

- /Users/classner/git/forpy/include/forpy/deciders/fastdecider.h