forpy  2
forpy::ClassificationTree Class Reference

#include <tree.h>

Inheritance diagram for forpy::ClassificationTree:
forpy::Tree

Public Member Functions

 ClassificationTree (const std::string &filename)
 
 ClassificationTree (const uint &max_depth=std::numeric_limits< uint >::max(), const uint &min_samples_at_leaf=1, const uint &min_samples_at_node=2, const uint &n_valid_features_to_use=0, const bool &autoscale_valid_features=false, const uint &random_seed=1, const size_t &n_thresholds=0, const float &gain_threshold=1E-7f)
 
std::unordered_map< std::string, mu::variant< uint, size_t, float, bool > > get_params (const bool &=false) const
 
std::shared_ptr< ClassificationTreeset_params (const std::unordered_map< std::string, mu::variant< uint, size_t, float, bool >> &params)
 
- Public Member Functions inherited from forpy::Tree
 Tree (const uint &max_depth=std::numeric_limits< uint >::max(), const uint &min_samples_at_leaf=1, const uint &min_samples_at_node=2, const std::shared_ptr< IDecider > &decider=nullptr, const std::shared_ptr< ILeaf > &leaf_manager=nullptr, const uint &random_seed=1)
 The standard constructor for the forpy trees. More...
 
 Tree (std::string filename)
 Deserialization constructor for the forpy trees. More...
 
void make_node (const IDataProvider *data_provider, Desk *d)
 Handle the creation of one tree node. More...
 
void DFS (const IDataProvider *data_provider, const ECompletionLevel &completion, Desk *d)
 Do one DFS step with given completion level. More...
 
void parallel_DFS (Desk *d, TodoMark &mark, IDataProvider *data_provider, const bool &finalize=true)
 
void DFS_and_store (Desk *d, TodoMark &mark, const IDataProvider *dprov, const ECompletionLevel &comp)
 
size_t get_depth () const
 
Treefit (const Data< MatCRef > &data_v, const Data< MatCRef > &annotation_v, const size_t &n_threads, const bool &complete_dfs=true, const std::vector< float > &weights=std::vector< float >())
 Standard fitting function. More...
 
Treefit_dprov (std::shared_ptr< IDataProvider > data_provider, const bool &complete_dfs=true)
 The fitting function for a single tree. More...
 
id_t predict_leaf (const Data< MatCRef > &data, const id_t &start_node=0, const std::function< void(void *)> &dptf=nullptr) const
 Get the leaf id of the leaf where the given data will arrive. More...
 
Data< Matpredict (const Data< MatCRef > &data_v, const int &num_threads=1, const bool &use_fast_prediction_if_available=true, const bool &predict_proba=false, const bool &for_forest=false)
 
Data< Matpredict_proba (const Data< MatCRef > &data_v, const int &num_threads=1, const bool &use_fast_prediction_if_available=true)
 Overload for consistency with the sklearn interface. More...
 
Data< Matpredict_leaf_result (const Data< MatCRef > &data, const id_t &start_node=0, const std::function< void(void *)> &dptf=nullptr) const
 Get the data prediction result for the given data. More...
 
Data< Matcombine_leaf_results (const std::vector< Data< Mat >> &leaf_results, const Vec< float > &weights=Vec< float >(), const bool &predict_proba=false) const
 
bool is_initialized () const
 Whether the trees fit method has been called and its DFS and BFS methods can now be used. More...
 
float get_weight () const
 The tree weight. More...
 
size_t get_n_nodes () const
 The number of tree nodes. More...
 
void set_weight (const float &new_weight)
 Sets the tree weight. More...
 
size_t get_input_data_dimensions () const
 The data dimension that is required by this tree. More...
 
std::shared_ptr< const IDeciderget_decider () const
 The classifier manager used by this tree. More...
 
std::shared_ptr< const ILeafget_leaf_manager () const
 The leaf manager used by this tree. More...
 
size_t get_samples_stored () const
 The number of samples stored in leafs. More...
 
const std::vector< std::pair< id_t, id_t > > get_tree () const
 
void enable_fast_prediction ()
 
void disable_fast_prediction ()
 
bool operator== (Tree const &rhs) const
 
void save (const std::string &filename) const
 Save the tree. More...
 

Private Member Functions

template<class Archive >
void serialize (Archive &ar, const uint &)
 
 DISALLOW_COPY_AND_ASSIGN (ClassificationTree)
 

Private Attributes

std::unordered_map< std::string, mu::variant< uint, size_t, float, bool > > params
 

Friends

class cereal::access
 
std::ostream & operator<< (std::ostream &stream, const ClassificationTree &self)
 

Detailed Description

Definition at line 376 of file tree.h.

Constructor & Destructor Documentation

◆ ClassificationTree() [1/2]

forpy::ClassificationTree::ClassificationTree ( const std::string &  filename)
inline

Definition at line 378 of file tree.h.

◆ ClassificationTree() [2/2]

forpy::ClassificationTree::ClassificationTree ( const uint max_depth = std::numeric_limits< uint >::max(),
const uint min_samples_at_leaf = 1,
const uint min_samples_at_node = 2,
const uint n_valid_features_to_use = 0,
const bool &  autoscale_valid_features = false,
const uint random_seed = 1,
const size_t &  n_thresholds = 0,
const float &  gain_threshold = 1E-7f 
)

Member Function Documentation

◆ DISALLOW_COPY_AND_ASSIGN()

forpy::ClassificationTree::DISALLOW_COPY_AND_ASSIGN ( ClassificationTree  )
private

◆ get_params()

std::unordered_map<std::string, mu::variant<uint, size_t, float, bool> > forpy::ClassificationTree::get_params ( const bool &  = false) const
inline

Definition at line 389 of file tree.h.

◆ serialize()

template<class Archive >
void forpy::ClassificationTree::serialize ( Archive &  ar,
const uint  
)
inlineprivate

Definition at line 419 of file tree.h.

◆ set_params()

std::shared_ptr<ClassificationTree> forpy::ClassificationTree::set_params ( const std::unordered_map< std::string, mu::variant< uint, size_t, float, bool >> &  params)
inline

Definition at line 393 of file tree.h.

Friends And Related Function Documentation

◆ cereal::access

friend class cereal::access
friend

Definition at line 417 of file tree.h.

◆ operator<<

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

Definition at line 408 of file tree.h.

Member Data Documentation

◆ params

std::unordered_map<std::string, mu::variant<uint, size_t, float, bool> > forpy::ClassificationTree::params
private

Definition at line 412 of file tree.h.


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