41 #include <pcl/ml/dt/decision_tree.h>
42 #include <pcl/ml/feature_handler.h>
43 #include <pcl/ml/stats_estimator.h>
49 template <
class FeatureType,
58 template <
class FeatureType,
67 template <
class FeatureType,
79 std::vector<ExampleIndex>& examples,
80 std::vector<LabelType>& label_data)
82 const std::size_t num_of_examples = examples.size();
83 label_data.resize(num_of_examples);
84 for (
int example_index = 0; example_index < num_of_examples; ++example_index) {
85 NodeType* node = &(tree.
getRoot());
87 while (node->sub_nodes.size() != 0) {
88 float feature_result = 0.0f;
89 unsigned char flag = 0;
90 unsigned char branch_index = 0;
93 node->feature, data_set, examples[example_index], feature_result, flag);
95 feature_result, flag, node->threshold, branch_index);
97 node = &(node->sub_nodes[branch_index]);
100 label_data[example_index] = stats_estimator.
getLabelOfNode(*node);
104 template <
class FeatureType,
117 std::vector<ExampleIndex>& examples,
118 std::vector<LabelType>& label_data)
120 const std::size_t num_of_examples = examples.size();
121 for (
int example_index = 0; example_index < num_of_examples; ++example_index) {
122 NodeType* node = &(tree.
getRoot());
124 while (node->sub_nodes.size() != 0) {
125 float feature_result = 0.0f;
126 unsigned char flag = 0;
127 unsigned char branch_index = 0;
130 node->feature, data_set, examples[example_index], feature_result, flag);
132 feature_result, flag, node->threshold, branch_index);
134 node = &(node->sub_nodes[branch_index]);
137 label_data[example_index] += stats_estimator.
getLabelOfNode(*node);
141 template <
class FeatureType,
153 ExampleIndex example,
156 NodeType* node = &(tree.
getRoot());
158 while (!node->sub_nodes.empty()) {
159 float feature_result = 0.0f;
160 unsigned char flag = 0;
161 unsigned char branch_index = 0;
164 node->feature, data_set, example, feature_result, flag);
166 feature_result, flag, node->threshold, branch_index);
168 node = &(node->sub_nodes[branch_index]);
174 template <
class FeatureType,
186 std::vector<ExampleIndex>& examples,
187 std::vector<NodeType*>& nodes)
189 const std::size_t num_of_examples = examples.size();
190 for (
int example_index = 0; example_index < num_of_examples; ++example_index) {
191 NodeType* node = &(tree.
getRoot());
193 while (node->sub_nodes.size() != 0) {
194 float feature_result = 0.0f;
195 unsigned char flag = 0;
196 unsigned char branch_index = 0;
199 node->feature, data_set, examples[example_index], feature_result, flag);
201 feature_result, node->threshold, flag, branch_index);
203 node = &(node->subNodes[branch_index]);
206 nodes.push_back(node);