42 #include <pcl/ml/dt/decision_tree.h>
43 #include <pcl/ml/feature_handler.h>
44 #include <pcl/ml/stats_estimator.h>
48 template <
class FeatureType,
57 template <
class FeatureType,
66 template <
class FeatureType,
78 std::vector<ExampleIndex>& examples,
79 std::vector<LabelType>& label_data)
81 const std::size_t num_of_examples = examples.size();
82 label_data.resize(num_of_examples);
83 for (
int example_index = 0; example_index < num_of_examples; ++example_index) {
84 NodeType* node = &(tree.
getRoot());
86 while (node->sub_nodes.size() != 0) {
87 float feature_result = 0.0f;
88 unsigned char flag = 0;
89 unsigned char branch_index = 0;
92 node->feature, data_set, examples[example_index], feature_result, flag);
94 feature_result, flag, node->threshold, branch_index);
96 node = &(node->sub_nodes[branch_index]);
103 template <
class FeatureType,
116 std::vector<ExampleIndex>& examples,
117 std::vector<LabelType>& label_data)
119 const std::size_t num_of_examples = examples.size();
120 for (
int example_index = 0; example_index < num_of_examples; ++example_index) {
121 NodeType* node = &(tree.
getRoot());
123 while (node->sub_nodes.size() != 0) {
124 float feature_result = 0.0f;
125 unsigned char flag = 0;
126 unsigned char branch_index = 0;
129 node->feature, data_set, examples[example_index], feature_result, flag);
131 feature_result, flag, node->threshold, branch_index);
133 node = &(node->sub_nodes[branch_index]);
136 label_data[example_index] += stats_estimator.
getLabelOfNode(*node);
140 template <
class FeatureType,
152 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);