decisiontree.hpp
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2019-2023, NVIDIA CORPORATION.
3  * SPDX-License-Identifier: Apache-2.0
4  */
5 
6 #pragma once
7 
8 #include "algo_helper.h"
9 #include "flatnode.h"
10 
11 #include <string>
12 #include <vector>
13 
14 namespace ML {
15 
16 namespace DT {
17 
22  int max_depth;
30  float max_features;
51  float min_impurity_decrease = 0.0f;
52 
58 };
59 
79  int cfg_max_depth = -1,
80  int cfg_max_leaves = -1,
81  float cfg_max_features = 1.0f,
82  int cfg_max_n_bins = 128,
83  int cfg_min_samples_leaf = 1,
84  int cfg_min_samples_split = 2,
85  float cfg_min_impurity_decrease = 0.0f,
86  CRITERION cfg_split_criterion = CRITERION_END,
87  int cfg_max_batch_size = 4096);
88 
89 template <class T, class L>
91  int treeid;
94  double train_time;
95  std::vector<T> vector_leaf;
96  std::vector<SparseTreeNode<T, L>> sparsetree;
98 };
99 
107 template <class T, class L>
109 
117 template <class T, class L>
118 std::string get_tree_text(const TreeMetaDataNode<T, L>* tree);
119 
127 template <class T, class L>
128 std::string get_tree_json(const TreeMetaDataNode<T, L>* tree);
129 
134 
135 } // End namespace DT
136 } // End namespace ML
Definition: params.hpp:23
TreeMetaDataNode< double, double > TreeRegressorD
Definition: decisiontree.hpp:133
void set_tree_params(DecisionTreeParams ¶ms, int cfg_max_depth=-1, int cfg_max_leaves=-1, float cfg_max_features=1.0f, int cfg_max_n_bins=128, int cfg_min_samples_leaf=1, int cfg_min_samples_split=2, float cfg_min_impurity_decrease=0.0f, CRITERION cfg_split_criterion=CRITERION_END, int cfg_max_batch_size=4096)
Set all DecisionTreeParams members.
std::string get_tree_text(const TreeMetaDataNode< T, L > *tree)
Obtain detailed tree information.
std::string get_tree_json(const TreeMetaDataNode< T, L > *tree)
Export tree as a JSON string.
std::string get_tree_summary_text(const TreeMetaDataNode< T, L > *tree)
Obtain high-level tree information.
TreeMetaDataNode< double, int > TreeClassifierD
Definition: decisiontree.hpp:131
TreeMetaDataNode< float, float > TreeRegressorF
Definition: decisiontree.hpp:132
TreeMetaDataNode< float, int > TreeClassifierF
Definition: decisiontree.hpp:130
Definition: dbscan.hpp:18
CRITERION
Definition: algo_helper.h:9
@ CRITERION_END
Definition: algo_helper.h:17
Definition: decisiontree.hpp:18
int max_batch_size
Definition: decisiontree.hpp:57
int max_n_bins
Definition: decisiontree.hpp:34
CRITERION split_criterion
Definition: decisiontree.hpp:46
float max_features
Definition: decisiontree.hpp:30
int min_samples_leaf
Definition: decisiontree.hpp:38
int max_depth
Definition: decisiontree.hpp:22
float min_impurity_decrease
Definition: decisiontree.hpp:51
int min_samples_split
Definition: decisiontree.hpp:42
int max_leaves
Definition: decisiontree.hpp:26
Definition: decisiontree.hpp:90
std::vector< T > vector_leaf
Definition: decisiontree.hpp:95
double train_time
Definition: decisiontree.hpp:94
int leaf_counter
Definition: decisiontree.hpp:93
int treeid
Definition: decisiontree.hpp:91
std::vector< SparseTreeNode< T, L > > sparsetree
Definition: decisiontree.hpp:96
int num_outputs
Definition: decisiontree.hpp:97
int depth_counter
Definition: decisiontree.hpp:92