decisiontree.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019-2023, NVIDIA CORPORATION.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #include "algo_helper.h"
20 #include "flatnode.h"
21 
22 #include <string>
23 #include <vector>
24 
25 namespace ML {
26 
27 namespace DT {
28 
33  int max_depth;
41  float max_features;
62  float min_impurity_decrease = 0.0f;
63 
69 };
70 
90  int cfg_max_depth = -1,
91  int cfg_max_leaves = -1,
92  float cfg_max_features = 1.0f,
93  int cfg_max_n_bins = 128,
94  int cfg_min_samples_leaf = 1,
95  int cfg_min_samples_split = 2,
96  float cfg_min_impurity_decrease = 0.0f,
97  CRITERION cfg_split_criterion = CRITERION_END,
98  int cfg_max_batch_size = 4096);
99 
100 template <class T, class L>
102  int treeid;
105  double train_time;
106  std::vector<T> vector_leaf;
107  std::vector<SparseTreeNode<T, L>> sparsetree;
109 };
110 
118 template <class T, class L>
120 
128 template <class T, class L>
129 std::string get_tree_text(const TreeMetaDataNode<T, L>* tree);
130 
138 template <class T, class L>
139 std::string get_tree_json(const TreeMetaDataNode<T, L>* tree);
140 
145 
146 } // End namespace DT
147 } // End namespace ML
Definition: params.hpp:34
TreeMetaDataNode< double, double > TreeRegressorD
Definition: decisiontree.hpp:144
void set_tree_params(DecisionTreeParams &params, 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:142
TreeMetaDataNode< float, float > TreeRegressorF
Definition: decisiontree.hpp:143
TreeMetaDataNode< float, int > TreeClassifierF
Definition: decisiontree.hpp:141
Definition: dbscan.hpp:30
CRITERION
Definition: algo_helper.h:20
@ CRITERION_END
Definition: algo_helper.h:28
Definition: decisiontree.hpp:29
int max_batch_size
Definition: decisiontree.hpp:68
int max_n_bins
Definition: decisiontree.hpp:45
CRITERION split_criterion
Definition: decisiontree.hpp:57
float max_features
Definition: decisiontree.hpp:41
int min_samples_leaf
Definition: decisiontree.hpp:49
int max_depth
Definition: decisiontree.hpp:33
float min_impurity_decrease
Definition: decisiontree.hpp:62
int min_samples_split
Definition: decisiontree.hpp:53
int max_leaves
Definition: decisiontree.hpp:37
Definition: decisiontree.hpp:101
std::vector< T > vector_leaf
Definition: decisiontree.hpp:106
double train_time
Definition: decisiontree.hpp:105
int leaf_counter
Definition: decisiontree.hpp:104
int treeid
Definition: decisiontree.hpp:102
std::vector< SparseTreeNode< T, L > > sparsetree
Definition: decisiontree.hpp:107
int num_outputs
Definition: decisiontree.hpp:108
int depth_counter
Definition: decisiontree.hpp:103